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

How to make dissapper on touch?

ok so i want when they touch the part it dissappers then after it waits 20 it reappers?

Heres what i tried im not that good with scripting

while true do
	onTouch()
	 part.Brick.Transperancy = 0
	wait(20)
end

2 answers

✓ Accepted answer

You need to use the Touched event to detect when an object is touched! You also want to check if it's a player! One last thing, there is no need for a loop! Just use a debounce.

debounce = false

script.Parent.Touched:connect(function(hit) -- Goes directly into the part
	if hit.Parent and game.Players:GetPlayerFromCharacter() and debounce == false then
		debounce = true
		script.Parent.Transparency = 1 -- 1 is invisible!
		wait(20)
		debounce = false
		script.Parent.Transparency = 0
	end
end)

You need to define a function.


function    onTouch()
   script.Parent:Destroy()
    wait(20)
end
script.Parent.Touched:connect(onTouch)

also, use Destroy(). Transparency just makes it invisible.

Hope this helped.

-ds

2 comments

0

He also wanted it to reappear, don't forget that!

0

Sorry.

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