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

Why is my GUI not popping up when I click a button?

Asked by 5 years ago

I am currently having a problem where when i click a button it will not pop up the gui, please help:

1local sd = game.StarterGui.SchoolShopGUI.DirtSwordInfo
2 
3script.Parent.MouseButton1Click:Connect(function()
4    sd.Visible = true
5end)
0
StarterGui is a Server Replication Container. It’s contents are stored in another container called PlayerGui upon the Client loading. To actively modify the UI, you must reference PlayerGui instead. Ziffixture 6913 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Try this.

1local plr = game.Players.LocalPlayer
2local sd = plr.PlayerGui.SchoolShopGUI.DirtSwordInfo
3 
4script.Parent.MouseButton1Click:Connect(function()
5    sd.Visible = true
6end)

Also, make sure this is a localscript.

0
I did the exact thing and it did not work. AronIZCool 11 — 5y
Ad
Log in to vote
0
Answered by
0msh 333 Moderation Voter
5 years ago

I don't see an error in the script unless what you're trying to set visible to true to is not a frame or anything without the property of "Visible". Maybe add wait() or WaitForChild

1local plr = game.Players.LocalPlayer
2wait()
3local sd = plr:WaitForChild("PlayerGui"):WaitForChild("SchoolShopGUI").DirtSwordInfo
4 
5script.Parent.MouseButton1Click:Connect(function()
6    sd.Visible = true
7end)
0
Please don’t use recursive methods, make a new variable for each set., or store the Script as a descendant of the respective GUI to eliminate load issues altogether. Following that example, apply script:FindFirstAncestor("DirtSwordInfo") Ziffixture 6913 — 5y

Answer this question