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

I'm trying to get a click Detector script to work. But how?

When I try to make a click detector script. I always get an error, how do I make it work?

Please help!

Here is what I have or what I think:

function onClicked.Clickdetector()

4 answers

✓ Accepted answer

Here is what you do:

function onClicked()
--code
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Hi, I recommend reading this small article. It will help your understanding a lot! Please vote this answer up if it helped you, and accept my answer if it works out in the end!

wiki.roblox.com/index.php/Making_an_onClicked_script

4 comments

0

Thank you so much! I would upvote but I don't have 1 rep!

1

you do now ;) and remember to check the wiki for basic scripting :)

1

Done! Thanks! This helped me so much! I figured out how to create a disco floor!

0

great job!

You can also do this:

script.Parent.TouchDetector.MouseClick:connect(function()
--What you want to happen when clicked
end

This is what I do:

ClickDetector = script.Parent

ClickDetector.MouseClick:connect(function(CanCollide)
workspace.Part.CanCollide = false
end

Just so you know, this is just an example.

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