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

Brick that gives you GUI when you click on it doesn't work. Why?

Asked by 6 years ago

I made button brick, when you click on it, it shows a Selection Box and a GUI. But for some reason it doesn't work. This is my script;

local gui = script.Gui:clone()

function onClicked(Part)
    if not Player.PlayerGui:FindFirstChild("Gui") then
        gui.Parent = Player.PlayerGui
        gui.LocalScript.Disabled = false
    end
        script.Parent.SelectionBox.Visible = true
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

What went wrong in this?

1 answer

Log in to vote
0
Answered by 6 years ago
local gui = script.Gui:clone()

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    if not Player.PlayerGui:FindFirstChild("Gui") then
        gui.Parent = Player.PlayerGui
        gui.LocalScript.Disabled = false
    end
        script.Parent.SelectionBox.Visible = true
    end)

I don't think you were getting the player value... Try this.

Ad

Answer this question