Lua 为什么我的脚本只在我的类人/noob上运行一次?

Lua 为什么我的脚本只在我的类人/noob上运行一次?,lua,roblox,Lua,Roblox,这是我的密码: game.Workspace.Demons_Boss.Humanoid.Died:connect(function() for i, v in pairs(game.Players:GetChildren()) do v.PlayerGui.ScreenGui.MagesWin.Visible = true v.PlayerGui.ScreenGui.DemonsWin.Visible = false v.PlayerGui.SreenGui.MagesWin.LocalScri

这是我的密码:

game.Workspace.Demons_Boss.Humanoid.Died:connect(function()
for i, v in pairs(game.Players:GetChildren()) do
v.PlayerGui.ScreenGui.MagesWin.Visible = true
v.PlayerGui.ScreenGui.DemonsWin.Visible = false
v.PlayerGui.SreenGui.MagesWin.LocalScript.Disabled = false
end
end)
我知道我的代码只运行一次,因为我试图打印一些东西,但它在输出中只运行了一次。在humanoid/noob模型中,我还添加了一个regen脚本。如果您需要我的regen脚本,它是:

name = "Humanoid"

robo = script.Parent:Clone()

While true do
wait(3)
if script.Parent.Humanoid.Health <1 then
robot = robo:Clone()
robot.Parent = script.Parent.Parent
robot:MakeJoints()
script.Parent:remove()
wait(7)
local p = game.Players:GetChildren()
for i = 1,#p do
p[i].Character.Head:remove()
end
end
end
name=“类人”
robo=script.Parent:Clone()
尽管如此
等等(3)

如果script.Parent.Humanoid.Health之后有一个

游戏。工作区


而不是,如果人形机器人死亡并且其角色被删除,则事件断开连接

您的代码中有一个输入错误。在第1行,您键入了逗号而不是点:

game.Workspace,Demons_Boss.Humanoid.Died:connect(function()
应将该行替换为:

workspace["Demons_Boss"].Humanoid.Died:connect(function()

请注意,“工作区”等同于“game.workspace”。

另一种解决方案是:

game.Workspace,Demons_Boss.Humanoid.Died:connect(function()
应该是

game.Workspace["Demons_Boss"].Humanoid.Died:connect(function()

为了提供真正的帮助,您的答案应该指出哪个
是错误的。不只是说一些相当于“某处有错误”的话。这是我问题中的一个错误。在我的代码中,我编写了game.Workspace.Demons\u Boss。