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 a script that makes a brick disappear for 5 seconds once you touch it?

I want to make a door for a place that disappears when you touch it, but comes back after 5 seconds.

1 comment

0

May we see your attempt?

4 answers

Script must be inside door

function onTouched(part)
if part.Parent:findFirstChild("Humanoid") then
script.Disabled = true
script.Parent.Transparency = 1
script.Parent.CanCollide = false
wait(5)
script.Disabled = false
script.Parent.Transparency = 0
script.Parent.CanCollide = true
end
end


script.Parent.Touched:connect(onTouched)

1 comment

0

Disabling the script would stop it from continuing anymore.

function onTouch(hit)
    if hit.Parent then
        if hit.Parent:FindFirstChild('Humanoid') then
            script.Parent.Transparency = 1
            script.Parent.CanCollide = false
            wait(5)
            script.Parent.Transparency = 0
            script.Parent.CanCollide = true
        end
    end
end
script.Parent.Touched:connect(onTouch)

function onTouched(part)
if part.Parent:findFirstChild("Humanoid") then
script.Parent.Transparency = 1
script.Parent.CanCollide = false --I would use Vector3.new() becuase it will slide away and not become invisible
wait(5)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
end
end
	 
script.Parent.Touched:connect(onTouched)

Vector3.new(98,878,90909) will make it look a bit better, Ether way its your door or whatever you are making.

function onTouch(hit)
	if hit.Parent then
		if hit.Parent:FindFirstChild('Humanoid') then
			script.Parent.Transparency = 1
			wait(5)
		end
	end
end
script.Parent.Touched:connect(onTouch)

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