the script i been trying is this but i dont understand. would you put it under the click detector or do you put it under the part?
clickDetector.MouseClick:connect(function() script.Parent.Part.Anchored = false end)
local clickDetector = Instance.new("ClickDetector") local part = game.Workspace.Part part.Parent = clickDetector script.Parent.MouseClick:Connect(function () part.Anchored = false end)
This is a easier and simpler method.
You need to identify a proper function. A basic one would be
function onClicked()
Put that at the beginning of your script.
There's also another flaw with the script, you have ClickDetector right in the middle, without identifying it. Identifying a ClickDetector would be:
local clickDetector = script.Parent.ClickDetector
You must also have a part with two aspects. A ClickDetector, and a Script. Do not put the script in the ClickDetector, or the ClickDetector in the script, they go in the part.
That makes it easier to unanchor your part like this:
script.Parent.Anchored = false
Hope this helps you.
Usally when I use click detectors i fire events with local scripts in starter gui. Create a local script in starter gui, and put a remote event in replicated storage. Your click detector should be under the part, and you can removethe old script you had.
local clickDetector = game.Workspace.Part:FindFirstChild:("ClickDetector") local event = game.ReplicatedStorage.RemoteEvent clickDetector.MouseClick:Connect(function() event:FireServer() end)
then have a script in workspace and put this in.
local event = game.Workspace.RemoteEvent local part = game.Workspace.Part event.OnServerEvent:Connect(function() part.Anchored = false end)
hope this works!
Make sure the ClickDetector
and the script is under the part you want to be unanchored.
This is how I would do it:
local part = script.Parent --gets the part to be anchored/unanchored local anchored = true part.ClickDetector.MouseClick:Connect(function() if anchored then --checks if part is anchored anchored = false part.Anchored = anchored --turns anchored into false else --if unanchored then anchored = true part.Anchored = anchored --turns anchored into true end end)
This way, you can anchor/unanchored the part over and over again. ;)
Simplest way, the rest are fine and good but are way more complicated. This one is easier to understand and learn in general.
-- Insert Part into Workspace -- Insert ClickDetector into Part -- Insert Script into ClickDetector and type the below out script.Parent.MouseClick:Connect(function() script.Parent.Parent.Anchored = false script.Parent:Destroy() -- Destroying ClickDetector since part already un-anchored. Remove this line if you want to keep ClickDetector print("Works Fine Dude") -- Making sure it works end)