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

Click Detector not working with local scripts or remote events?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
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. XxTrueDemonxX 362 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(function()  
workspace.Baseplate.Transparency = 1  
end)
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. XxTrueDemonxX 362 — 5y
0
Any luck with this?Doesn't work for me in LocalScript only as well. Works as expected under server script. choppedwood 0 — 4y
0
omg so long since i was on here but, those scripts should be server scripts Gameplayer365247v2 1055 — 4y

Answer this question