Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make an image button make a part switch the "CanCollide" feature on and off?

Asked by 4 years ago
Edited 4 years ago

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")
0
Is that a serverscript or a localscript, and where is it parented? Time_URSS 146 — 4y
0
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. Benbebop 1049 — 4y
0
also to get the clients gui use Players.LocalPlayer.PlayerGui Benbebop 1049 — 4y
0
The script itself is a localscript, and it is parented to the GhostPart. billybobjoe1212341 0 — 4y

Answer this question