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

button opening door?

hi guys this is my script but i dont know why it does not work

function lefttClick(playerWhoClicked)
script.Parent.Parent.trapdoor.Transparency=0.6
script.Parent.Parent.trapdoor.CanCollide=false
wait(2)
script.Parent.Parent.trapdoor.Transparency=0
script.Parent.Parent.trapdoor.CanCollide=true

end
Workspace.Part.ClickDetector.MouseClick:connect(function rightClick(playerWhoClicked)
do i have to include a if then statement?
or..

1 answer

Hi, to start this off, if you want to add comments to a script, instead of writing it out inside of the script, use the comment feature,

--it looks something like this, just use 2 '--'s before writing something.

Now, with your problem, try this:

script.Parent.ClickDetector.MouseClick:connect(function()
script.Parent.Transparency=0.6
script.Parent.CanCollide=false
wait(2)
script.Parent.Transparency=0
script.Parent.CanCollide=true
end)

One thing I should note is that the script should be inside of the brick that is going to be doing this. It makes scripts so much easier instead of working with a script outside of the part. Simply cut and paste the script inside of the part in Properties.

Also, leftClick I believe is not a valid event, so you would have to do MouseClick. I would recommend the following wiki article on ClickDetector and how it works, if you wanted to get more in-depth with scripts like this. http://wiki.roblox.com/index.php?title=Clickdetector

Give +1 rep if I helped.

1 comment

0

do i put the script within the click detector..also i thought you could name your function anything so i named it leftlcick

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