Roblox 脚本只能运行一次
我正在编写一个脚本,可以改变你的团队并在你死后打开一个 Gui,但它只能工作一次。
这是我的脚本,我将其放入 ServerScriptSevice
中:
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local gui = player.PlayerGui:FindFirstChild("TeamGUI"):WaitForChild("Background")
player.TeamColor = game.Teams:findFirstChild("Choosing").TeamColor
wait(3)
gui.Visible = true
end)
end)
end)
我不知道为什么,但只有 Teamcolor 可以工作几次,而 Gui 可以工作一次。
I'm working on a script that change your team and open a Gui when you die, but it only work onetime.
Here is my script, I put it into ServerScriptSevice
:
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local gui = player.PlayerGui:FindFirstChild("TeamGUI"):WaitForChild("Background")
player.TeamColor = game.Teams:findFirstChild("Choosing").TeamColor
wait(3)
gui.Visible = true
end)
end)
end)
I don't know why but only the Teamcolor works several times and the Gui once.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为您的事件仅在玩家加入时才有效,
您的脚本如下所示:
玩家加入 AND 死亡,然后 gui 出现,
您需要执行以下操作:
玩家加入 OR
在 LocalScript 中像这样
死亡,尝试此操作,如果不起作用,则发表评论
it's because your event works only when player joins
your script works like:
Player joined AND died then gui appears
you need to do:
Player Joined OR Dies
like this in LocalScript
try this, if its not work then comment
在这里尝试一下,它应该
基本上起作用我所做的是设置一个事件,每当您的角色死亡时都会听
here try this, it should work
basically what I did was set up an event that listens for whenever your character has died