My code is here:
function opengui() local plr = game.Players.LocalPlayer function opengui() local shopgui = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("ShopGui") local guiclone = shopgui:Clone() guiclone.Parent = plr.StarterGui end end script.Parent.Start.MouseButton1Click:connect(opengui)
It should open shopgui, but just doesn't. It's in a localscript.
Edit: I should probably mention that the GUI being clicked is a SurfaceGUI and the GUI being opened is a ScreenGUI.
Edit 2: I butchered this so bad. Going to sleep. Still doesn't work with the following code:
local plr = game.Players.LocalPlayer function opengui() local shopgui = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("ShopGui") local guiclone = shopgui:Clone() guiclone.Parent = plr.PlayerGui end script.Parent.Start.MouseButton1Click:connect(opengui)
You have nested functions with the same name. This will cause your script to not work as your script is going by the first function and will not run the second. In addition, placing a gui in the StarterGui after a player spawns will not cause them to see the new gui until they respawn and this would affect all players not just the LocalPlayer. I have fixed your script and this should work. Also, if ShopGui is already in the Playergui, the only thing you must do is make it visible. If you want this you will have to edit this script because this is only set up to do what your script was meant to do.
local plr = game.Players.LocalPlayer function opengui() local shopgui = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("ShopGui") shopgui:Clone().Parent = plr.PlayerGui end script.Parent.Start.MouseButton1Click:connect(opengui)
Your code is inside another function layer, and yet both those functions are named the same. Although you shouldn't have even used two functions with the same name at all, you would expect it to work anyways as the second function overwrites the first.. due to the same names.
BUT, the second function will not overwrite the first function without the initial call of the first function.
Just make it one function(:
local plr = game.Players.LocalPlayer function opengui() local shopgui = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("ShopGui") local guiclone = shopgui:Clone() guiclone.Parent = plr.StarterGui end script.Parent.Start.MouseButton1Click:connect(opengui)