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

Click to add GUI?[SOLVED]

Asked by 9 years ago

I'm trying to make a button that opens a GUI when it's clicked

GUI = script.Parent.ShopGUI:Clone()

function Click(hit)
    all = GUI:Clone()
    all.Parent = game.Players[Click]:FindFirstChild("PlayerGui")
end

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

Any help is appreciated! Thanks! SOLVED

1 answer

Log in to vote
1
Answered by
Lacryma 548 Moderation Voter
9 years ago

The solution is quite easy.

Click detectors provide the player as an argument when the mouseclick event occurs.

Also, the variable all should be omitted due to the fact that double cloning is unnecessary and using the variable GUI instead of all has the same effect.

GUI = script.Parent.ShopGUI:Clone()

function Click(player)
    GUI.Parent = player:FindFirstChild("PlayerGui")
end

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

Furthermore, I recommend that you check if the player has the playergui present.

0
Thanks! I figured it out the second you answered haha, but for the answer I accept and "One up" =D BSIncorporated 640 — 9y
Ad

Answer this question