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

Click Detector not working with local scripts or remote events?

So I'm fairly new to scripting and I'm working on something utilizing a click detector. I've read over some info on the developer thing from roblox where it says it'll work on both scripts and local scripts. Well, I wanted to adjust the camera with it but for some reason nothing happens. So I tried using something a bit simpler.

For example: script.Parent.ClickDetector.MouseClick:Connect(function() workspace.Baseplate.Transparency = 1 end) But nothing.

Even after running it through a remote event (script to local), passing the player who clicked, nothing happens. Is there something about the click detector that I'm missing? Does it just negate the use of remote events entirely or something?

2 answers

✓ Accepted answer

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

To make your script work, create a new LocalScript in one of the mentioned objects above. Now, we want to get the ClickDetector and use the MouseClick event to change the baseplate's transparency to 1. LocalScript's Code:

workspace.Part:WaitForChild("ClickDetector").MouseClick:Connect(function() -- Wait for the ClickDetector to load, then we connect the MouseClick event handler to an anonymous function
	workspace.Baseplate.Transparency = 1
end)

1 comment

0

Ahhh. That is a detail I never noticed before. Well, guess I'll have to keep that in mind in the future. Kinda a shame since I won't be able to copy paste the thing I'm creating but a bit of extra typing has never killed anyone. Thank you.

in ur example u need to wait for the clickdetector so do

script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(function()  
workspace.Baseplate.Transparency = 1  
end)

3 comments

0

Doesn't work. I've already tried with the correct event. Works fine in scripts of course but LocalScripts just don't seem to like it.

0

Any luck with this?Doesn't work for me in LocalScript only as well. Works as expected under server script.

0

omg so long since i was on here but, those scripts should be server scripts

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