Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to stop this script from looping over and over?

local Temp
Temp = workspace:WaitForChild("Temp").Changed:Connect(function(TempCheck)

while true do
	wait(2)
	if TempCheck == 200 then
	game.Workspace.Check1.Disabled = true
	Temp:Disconnect()
	local Melt = Instance.new("Hint", game.Workspace)
	Melt.Parent = game.Workspace
	Melt.Name = 'CoreHot'
	Melt.Text = '!Core is heating up!'
	script.Warning1:Play()
	wait(3)
end
end
end)

How to stop it from looping over and over.

1 answer

✓ Accepted answer

You're using a while true do loop. while true do loops loop over and over again and are unnecessary in this case.

local Temp
Temp = workspace:WaitForChild("Temp").Changed:Connect(function(TempCheck)


    wait(2)
    if TempCheck == 200 then
    game.Workspace.Check1.Disabled = true
    Temp:Disconnect()
    local Melt = Instance.new("Hint", game.Workspace)
    Melt.Parent = game.Workspace
    Melt.Name = 'CoreHot'
    Melt.Text = '!Core is heating up!'
    script.Warning1:Play()
    wait(3)
end

end)

It isn't very good to place a while true do loop inside an event, as it will no longer listen for it, and keep looping over and over.

2 comments

0

thx

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.