The script is supposed to detect items in Workspace and change accordingly to them. However, the script does not work at all, and I have no idea why, as output didn't give me anything.
Can someone please help me? Here's the script:
local GameOn = game.ServerScriptService.MainGame:WaitForChild("Playing") while wait(0.1) do if GameOn.Value == true then if game.Workspace:WaitForChild("Bomb") then if game.Workspace.Bomb:WaitForChild("Armed Bomb") then if game.Workspace.Bomb["Armed Bomb"].Armed.Value == true then script.Parent.Visible = true script.Parent.Start.Value = true script.Parent.Timer.Value = 60 end elseif game.Workspace.Bomb:WaitForChild("Defused Bomb") then script.Parent.Visible = false script.Parent.Start.Value = false script.Parent.Timer.Value = 0 end end end end
local GameOn = game.ServerScriptService.MainGame:WaitForChild("Playing") while wait(0.1) do if GameOn.Value == true then if game.Workspace:WaitForChild("Bomb") then if game.Workspace.Bomb:FindFirstChild("Armed Bomb") then if game.Workspace.Bomb["Armed Bomb"].Armed.Value == true then script.Parent.Visible = true script.Parent.Start.Value = true script.Parent.Timer.Value = 60 end elseif game.Workspace.Bomb:FindFirstChild("Defused Bomb") then script.Parent.Visible = false script.Parent.Start.Value = false script.Parent.Timer.Value = 0 end end end end
Now let me tell you what's wrong with this script. You used WaitForChild
. WaitForChild
is a yield, or something that waits for something. So this won't work. But this can be easily replaced by FindFirstChild
. FindFirstChild
won't return nil if it finds something, so in true/false statement terms. It will return true if something is found.
Written with StackEdit. by hungryjaffer