When ever I try testing my game in studio it tells me to kill this script. hy is it doing this ? its a local script inside starterplayerscripts
local status = game.ReplicatedStorage.InfoValue local plr = game.Players.LocalPlayer while true do if status.Value=='Round Beginning!' then wait(1.9) if game.Players.LocalPlayer.AFK.Value==1 then local torso = game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart') torso.Parent = game.Lighting game.Players.LocalPlayer.AFK.Value = game.Players.LocalPlayer.AFK.Value + 9 wait(2) end end end
The reason, is, if the status is not "round beginning", then there is no wait. Even if you had a
while true do end
loop, it would still ask you to kill it. To fix this, we should use a .Changed event.
local status = game.ReplicatedStorage.InfoValue local plr = game.Players.LocalPlayer status.Changed:Connect(function() if status.Value=='Round Beginning!' then wait(1.9) if game.Players.LocalPlayer.AFK.Value==1 then local torso = game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart') torso.Parent = game.Lighting game.Players.LocalPlayer.AFK.Value = game.Players.LocalPlayer.AFK.Value + 9 wait(2) end end end)
That way, this only fires when necessary. If you find yourself using a infinite loop, try finding a event that you could use in that case if you can use events in that case.
Hope this helps!
It is cause u r hangin'
local status = game.ReplicatedStorage.InfoValue local plr = game.Players.LocalPlayer while wait() do if status.Value=='Round Beginning!' then wait(1.9) if game.Players.LocalPlayer.AFK.Value==1 then local torso = game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart') torso.Parent = game.Lighting game.Players.LocalPlayer.AFK.Value = game.Players.LocalPlayer.AFK.Value + 9 wait(2) end end end