i know this is a really stupid question and is probably pretty easy but i dont see why this script doesnt work
local debounce = false function onclicked() if debounce = false then script.Parent.Anchored=false end end clickDetector.MouseClick:connect(onMouseClick)
im using a local script btw
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)
local debounce = false clickDetector.MouseClick:connect(function() if debounce then return end debounce = true script.Parent.Anchored=false --optional, add a wait() to make debounce = false end)
Your problem:
When seeing if something is equal to another, you use ==
instead of =
.