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

How do I make it so it waits 60 seconds or until a part gets destroyed?

Is there a way to make it so a script waits 60 seconds or until something happens. For example, it waits 20 seconds, then a part gets destroyed so then it just heads to the next bit of code but if the part isn't destroyed, it waits 60 seconds then does the next bit of code.

I've tried

repeat wait() until game.Workspace:FindFirstChild(ClonedBuild.Name) == nil or wait(60)

but that doesn't do anything.

1 answer

That is not how the wait() command is supposed to be used. I also wouldn't use a repeat until loop in this case.

local waited60 = false
for i=1,60 do
	if game.Workspace:FindFirstChild(ClonedBuild.Name) == nil then
		
		--do the stuff
		break
	end
	wait(1)
	if i==60 then
		waited60 = true
	end
end
if waited60 then
	--do the stuff here too
end
--then the rest of your code

simply loops for 60 seconds checking the other parameter and if it triggers the if statement then it does whatever you want to happen, if not then it continues on to the rest of your code.

If this answers your question, then mark it as the accepted answer.

2 comments

0

you dont do bool waited you do local waited = false in lua

0

right sorry, got languages mixed up

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