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
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.