最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

lua - running roblox script only once - Stack Overflow

programmeradmin7浏览0评论
    part = script.Parent
    part.Touched:Connect(function(hit)
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr.PlayerGui.upd.Enabled = true
    end)

that script run only once, but must run any time player touching part. Why?

    part = script.Parent
    part.Touched:Connect(function(hit)
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr.PlayerGui.upd.Enabled = true
    end)

that script run only once, but must run any time player touching part. Why?

Share Improve this question asked Mar 27 at 11:26 YanichegoneumeyuYanichegoneumeyu 1 4
  • Are you sure it is only running once? If you put print("Touched") inside the function, does it only print once? I think your issue might not be in this code specifically. To better help you out, could you tell us what you are trying to do, and what you are seeing happen? – Kylaaa Commented Mar 27 at 14:19
  • I have a part. there are 2 similar scripts in it, which are activated by the same method - “touching the part”. this script should enable GUI and the other one should teleport. as soon as I run the test, the first time everything works perfectly, but in the rest of the repetitions in this session it doesn't work. And even if these 2 different codes are in 1 script. That is, both pieces of code will be executed in 1 script, but only the teleport will work. – Yanichegoneumeyu Commented Mar 27 at 16:11
  • Hi, I think it only run once because it get the player’s character, and make a GUI enabled, but I don’t think it’s getting disabled at any time, i’d recommand to make a part to disable it, and test the other part again. Hope this help ! – Buage Commented Mar 31 at 5:46
  • HI. i had a part like that what you mean. It work perfectly. Didnt work only script which turn it on – Yanichegoneumeyu Commented Mar 31 at 7:05
Add a comment  | 

1 Answer 1

Reset to default -1

I found the solution. I created a remote event that sent a request switch GUI to the client

发布评论

评论列表(0)

  1. 暂无评论