Seeing as it's already answered, I'll just add example's and explain it the best I can.
Did you put your full code here, what is clickDetector referring to? If you posted your full code here, it should be either script.Parent or script.Parent.ClickDetector unless you made a variable referring to it.
Here's a example:
local clickDetector = Instance.new("ClickDetector",script.Parent)
Like TheDeadlyPanther said, if you use the if statement, you have to use == not =.
And like TheAlphaStigma said, LocalScript's only replicate to the client, and do not work server-sided (unless put into the Players' Character).
You could also replace if debounce == false then to if not debounce then
Example:
local debounce = false
if not debounce then
print("I like cows.")
end
You can replace the function onclicked() and clickDetector.MouseClick:connect(onMouseClick) to clickDetector.MouseClick:connect(function() print("I like cows") end) to make it some-what shorter.
Example:
local clickDetector = Instance.new("ClickDetector",script.Parent)
clickDetector.MouseClick:connect(function()
print("I like cows")
end)
Final script:
local clickDetector = Instance.new("ClickDetector",script.Parent)
clickDetector.MouseClick:connect(function()
script.Parent.Part.Anchored = false
end)
If you want it to unanchor everything in a model.
local clickDetector = Instance.new("ClickDetector",script.Parent)
clickDetector.MouseClick:connect(function()
for _,v in pairs(game.Workspace.Model:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = false
end
end
end)
2 comments
Keep in mind to supply the errors you may get. This will help people solve the issue better.
Your problem is that you are using a 'LocalScript'; LocalScripts only replicate to the client, and do not work server-sided (unless put into the Players' Character). Please use a normal 'Script' instead, as that may solve your problem. :)