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 4 years ago

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

local sd = game.StarterGui.SchoolShopGUI.DirtSwordInfo

script.Parent.MouseButton1Click:Connect(function()
    sd.Visible = true
end)
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 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Try this.

local plr = game.Players.LocalPlayer
local sd = plr.PlayerGui.SchoolShopGUI.DirtSwordInfo

script.Parent.MouseButton1Click:Connect(function()
    sd.Visible = true
end)

Also, make sure this is a localscript.

0
I did the exact thing and it did not work. AronIZCool 11 — 4y
Ad
Log in to vote
0
Answered by
0msh 333 Moderation Voter
4 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

local plr = game.Players.LocalPlayer
wait()
local sd = plr:WaitForChild("PlayerGui"):WaitForChild("SchoolShopGUI").DirtSwordInfo

script.Parent.MouseButton1Click:Connect(function()
    sd.Visible = true
end)
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 — 4y

Answer this question