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

Button door help?

So basically, the script is about when a player steps on a part called Button, a message appears, dissapears, and the door opens, stays open for 10 seconds, and closes again. Is this right?

Message on touch script

local debounce = true
function onTouch(Part)
if debounce and Button.Parent:FindFirstChild("Humanoid") and Button.Parent.Name == game.Players:findFirstChild(Button.Parent.Name) then debounce = false
function onTouch(Part)
Instance.new("Message", game.Workspace.Part)
wait()
H.Message.Text("You can pass.")
end
 
script.Parent.Touched:connect(onTouch)

Door script

H = game.Workspace.Door

function onTouch(Button)
wait(5)
H.CanCollide = false
H.Transparency = 1
wait(10)
H.CanCollide = true
H.Transparency = 0
end

script.Parent.Touched:connect(onTouch)

1 comment

0

What's the error?

1 answer

✓ Accepted answer

Put this in the button.

door = game.Workspace.Door
button = script.Parent
button.Touched:connect(function(hit)
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
		p = game.Players:GetPlayerFromCharacter(hit.Parent)
		door.Transparency = 1
		door.CanCollide = false
		m = Instance.new("Hint", p.PlayerGui)
		m.Text = "You may now pass."
		wait(10)
		m:Destroy()
		door.CanCollide = true
		door.Transparency = 0
	end
end)

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