--Made by airkor local BuySword = game.StarterGui.ScreenGui.ShopGui:FindFirstChild("BuySwordFrame") script.Parent.MouseButton1Click:connect(function() if BuySword.Visible then BuySword.Visible = true end end)
Hi, I am trying to open a gui by clicking down on a button. Unfortunately, It would not work.
I tried numerous things but unfortunately, none worked, may anyone give me suggestions?
Edit: The local BuySword is not on another line of code as shown on here.
You are trying to access the startgui when there is a server running. That won't do anything you have to access the playergui in player. This is how you would do it:
for i, player in pairs (game.Players:GetChildren()) do local BuySword = player.PlayerGui.ScreenGui.ShopGui:FindFirstChild("BuySwordFrame") script.Parent.MouseButton1Click:connect(function() if BuySword.Visible == false then BuySword.Visible = true end end) end
Hope it helps!
Try using this instead of using
if BuySword.Visible then
BuySword.Visible = true
script.Parent.MouseButton1Click:connect(function() BuySword.Visible = not BuySword.Visible
By doing it, it just make it the opposite without using visible = true... full script
--Made by airkor local BuySword = game.StarterGui.ScreenGui.ShopGui:FindFirstChild("BuySwordFrame") script.Parent.MouseButton1Click:connect(function() BuySword.Visible = not BuySword.Visible end)
Try this out, it should work...
One problem is your changing the StarterGui
portion of it, that mean's when it's changed it won't be changed by the PlayerGui
unless they reset, so you could do game.Players.LocalPlayer.ScreenGui.ShopGui:FindFirstChild("BuySwordFrame")
in a LocalScript
.
Another problem is on line six, you did if BuySword.Visible then
, not if BuySword.Visible == false then
.
Server script:
--Made by airkor local BuySword = script.Parent.Parent:FindFirstChild("BuySwordFrame") script.Parent.MouseButton1Click:connect(function() if BuySword.Visible == false then BuySword.Visible = true end end)
Local script:
--Made by airkor local BuySword = game.Players.LocalPlayer.PlayerGui.ScreenGui.ShopGui:FindFirstChild("BuySwordFrame") script.Parent.MouseButton1Click:connect(function() if BuySword.Visible == false then BuySword.Visible = true end end)