Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with this script that opens a door?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by 10 years ago

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)
Ad

Answer this question