Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Click to add GUI?[SOLVED]

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

✓ Accepted answer

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.

1 comment

0

Thanks! I figured it out the second you answered haha, but for the answer I accept and "One up" =D

This discussion is preserved as it was. New answers, comments, and votes are closed.