I have tried to make an image button switch the "CanCollide" property on and off, but I seemed to have failed. I have looked close to everywhere I could and didn't find my answer. I am starting to get desperate and wanted to ask. Here is what I have done in my attempt. I also want it so the player can not affect the entire server, of course. ObbyParts is the folder that holds parts, GhostPart is the part I am trying to modify, and "Un Ghostified Button" is the off version of the image button.
local Button = game.StarterGui.ScreenGui.ImageButton
local function leftClick()
if Button.Image("rbxgameasset://Images/Un Ghostified Button") then
game.Workspace.ObbyParts.GhostPart.CanCollide = true
else
game.Workspace.ObbyParts.GhostPart.CanCollide = false
end
end
Button.MouseButton2Click:Connect("leftClick")

4 comments
Is that a serverscript or a localscript, and where is it parented?
You are trying to get the click event from the StarterGui, StarterGui copies its children into a spawned players PlayerGui (Which is what displays on the players screen). You will need to get the event from the players PlayerGui.
also to get the clients gui use Players.LocalPlayer.PlayerGui
The script itself is a localscript, and it is parented to the GhostPart.