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

What is wrong with this script that opens a door?

I have a Brick with a ScreenGui with a Button that opens a door

I have a script for it, but it doesn't work.

PlayButton = script.Parent -- (It is a TextButton)
door = PlayButton.Parent.Parent.Door -- (This is the door)

function Play()

	door.CanCollide = false
	door.Transparency = 0.7
wait(3)
	door.CanCollide = true
	door.Transparency = 0
end

PlayButton.MouseButton1Down:connect(Play)


This script doesn't work either:

PlayButton = script.Parent -- (It is a TextButton)
door = PlayButton.Parent.Parent.Door -- (This is the door)

function Play()

	door.CanCollide = false
	door.Transparency = 0.7
wait(3)
	door.CanCollide = true
	door.Transparency = 0
end

PlayButton.MouseClick:connect(Play)


How do I fix this?

1 answer

You are using the wrong methods. Go to this link and scroll down to the Events section.

debounce = false --Add a debounce so it doesn't spam.
PlayButton = script.Parent -- (It is a TextButton)
door = PlayButton.Parent.Parent.Door -- (This is the door)

function Play()
if not debounce then
debounce = true
    door.CanCollide = false
    door.Transparency = 0.7
wait(3)
    door.CanCollide = true
    door.Transparency = 0
debounce = false
end
end

PlayButton.MouseButton1Click:connect(Play)
PlayButton = script.Parent -- (It is a TextButton)
door = PlayButton.Parent.Parent.Door -- (This is the door)
debounce = false
function Play()
if not debounce then
debounce = true
    door.CanCollide = false
    door.Transparency = 0.7
wait(3)
    door.CanCollide = true
    door.Transparency = 0
debounce = false
end

PlayButton.MouseButton1Click:connect(Play)

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