I have a click detector in my model and a script, when i click on the model it should print somthing but it does not print anything(there are no Errors or Warnings) , and it is because the model is local (only specific player can see it). Can anyone tell me how to solve the problem?
script code :
local clickDetector = script.Parent.ClickDetector function onMouseClick(player) print(player.Name," clicked me!") end clickDetector.MouseClick:Connect(onMouseClick)
Your code is fine, but your script needs to be a Script (server Script) not a LocalScript. If you have a LocalScript, you'll see the hand icon but no code will execute. Likewise, if you have a server Script and somehow accidentally set it Disabled, it will also not work. Other than that, you just need for there to be at least one Part in the model to have something to click.
EDIT: I added a comment below, since you changed your question after I wrote my answer. You should add an edit note like this one if you change your question after it has answers, as you just made it look like I ignored your question and wrote an incorrect answer :-/ Your original question had no mention of the Model being locally-created. You have no choice but to use a LocalScript in this case, but you can't just put it in the Model. LocalScripts won't execute in the Workspace.