My code doesn’t fire the click event? I’ve tried everything and don’t know why. It’s just meant to change door colour when clicked.
A LocalScript
won’t run under the workspace
.
A LocalScript
can run in:
ReplicatedFirst
StarterGui
StarterPack
StarterCharacterScripts
StarterPlayerScripts
it still fails to work in starterplayerscripts though, nothing is fired
It should work in a LocalScript, but if for some reason it doesn’t work in a LocalScript, then put it inside of a normal script, and put the normal script inside of the clickdetector. It may also just be erroring because the part with the clickdetector loads in too slow, so adding a task.wait(1)
above everything in the script, might help negate errors too.
If you open up the output
window in roblox studio, it should be showing you errors that might help guide you in the right direction as to why something may not be working properly.
It works if i put it in a normal script and palce it inside of clickdetector, however I do want it to be local to the player
It should work if you copy and paste that exact script, put it in StarterPlayersScript but without the PlayerWhoClicked parameter (You don’t need that parameter, its a local script!)
If it still doesnt work, do:
local part = workspace:WaitForChild(“Door”)
Needed to change the variable, perfect, thank you!
The WaitForChild is necessary because sometimes the part isn’t loaded in when the script runs for some reason (I don’t know why honestly, I think it has to do with StreamingEnabled or whatever)
Interesting, I’ll remember that when debugging in the future, thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.