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

How can I make an onbject removed on touch then reappear after 90 seconds?

So far I managed to make the object become removed once touched, but I can't manage to have the parent of the script reappear successfully. I would like the parent to reappear after 90 seconds of being removed from the workspace. Any help?

script.Parent.Touched:connect(function()
	script.Parent:Destroy();
end)

3 comments

0

Accidentally said this on my answer also but, please accept my answer if it helped you out.

0

I'd be glad to. How can I do that for you?

0

Side note: I couldn't quite seem to get the script to work eithe.

1 answer

✓ Accepted answer

You can't actually make the part come back into the workspace unless you are talking about a completely new part. When you use the Destroy() you are completely removing it from your game until the server restarts. If you are talking about a completely new part, you would need to put the script somewhere else because all of the children of the part would also be destroyed. I myself would just change the parent of the part and change it back after 90 seconds. That would look something like this:

debounce = false

script.Parent.Touched:Connect(function()
	if not debounce then
		debounce = true
		script.Parent = game.ServerStorage
		wait(90)
		script.Parent = workspace
		debounce = false
	end
end)

Also, you should no longer be using :connect (talking about the lowercase "c"). That has been deprecated meaning it will no longer work in a later update, as a result, you should use ":Connect", with an uppercase "c". Hope I helped you out.

-cmgtotalyawesome

EDIT: If you were unsure of what the debounce did, it is just a way to keep the function from running over and over again, making it take longer than 90 seconds to put the part back, and also to avoid errors from the function.

8 comments

0

I can't tell you how much I appreciate this. I have such a mental block when it comes to getting this stuff. Thanks pal!

0

No problem, please accept my answer if I helped

0

I'm wondering why what you wrote me doesnt work. I tested the script on a basic brick, had my character touch it on a test run, and it wont seem to run properly. From what I can tell, whet you wrote seems to make sense. Is there something I could be doing wrong?

0

Is the part inside of the brick?

0

If it is and the script doesn’t work then please revoke the accepting of this answer, no points were deserved if that is the case.

0

If by part you mean script, then yes. I put the script inside the brick. Would you mind just taking a second look at the script? I think you certainly deserve the points! There must just be one funny, little error. If you don't have the chance, thanks anyway!

0

Yeah I’ll look over it again

0

Would you mind posting the script you have here? Even if it is copy and pasted i would like to see please

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