title. I made a local script where it should unanchor a part when you click it. I may be wrong but I think local scripts only happen to one player, hence the local name. so here’s the script.
Note: SUS is the part.
local SUS = script.Parent
local function DontFloat()
SUS.Anchored = false
end
MouseButton1Click:Connect(DontFloat())
Sorry if this question is extremely trivial, I’m very new.
Thank you.
welp i copy and pasted the code into a normal script. Still didn’t work though. Even if it did work, will the platform fall down only for that player?
Because if it affects the entire server, the level i’m making will be incredibly easy.
Also, you do not need to use the parameter ‘DontFloat()’ in the code: :Connect(DontFloat()), as just calling ‘DontFloat’ without the brackets runs the function.
Additionally, even if you were using a GUI element and running the MouseButton1Click event, make sure you specify the element using the event, and not calling it on it’s own like you did.
Try this code:
local SUS = script.Parent
local function DontFloat()
SUS.Anchored = false
end
SUS.ClickDetector.MouseClick:Connect(DontFloat)
Make sure it is a server script (not a local script) placed in the part.
Nowhere in your response did you say to use MouseClick. Additionally, I am teaching him the correct event used for click detectors, rather than giving him the full project.
In the future, don’t reply with unnecessary comments such as that, as I was helping him identify the error in his code.
local part = workspace.Part --> RENAME THIS TO YOUR PART NAME
function unanchor()
part.Anchored = false
end
part.ClickDetector.MouseClick:Connect(unanchor) --> UNACHORS WHEN PART CLICKED
local SUS:BasePart? = workspace:FindFirstChild("SUS") -- where does SUS belong?
local MouseClick = Instance.new("ClickDetector")
MouseClick.Parent = SUS
function Anchor()
SUS.Anchored = not SUS.Anchored
end
MouseClick.MouseClick:Connect(Anchor)