PlayerGui Visibility Help

  1. What do you want to achieve? I am trying to make a ticket station where you can buy tickets.

  2. What is the issue? The gui doesn’t open after a second time, but if I rest my character, I can access it another time.
    Sneaky-Theater-In-Building-Roblo

  3. What solutions have you tried so far? At first I cloned the gui, but that can create lots of them so I instead made it visible/not visible.

Code Screenshots


I am wondering why it won’t come back up.

1 Like

if plr.leaderstats.SneakyPoints.Value > 4 then
plr.leaderstats.SneakyPoints.Value = plr.leaderstats.SneakyPoints.Value - 5
end

This happends because you are argumenting if a player has less than 4 points, then you are getting 5 of 4 points, so your leaderstats value will be in -1+.

Try to change if plr.leaderstats.SneakyPoints.Value > 4 then to if plr.leaderstats.SneakyPoints.Value < 4 then, thats your error!

Hope thats help! Good luck in your project!

1 Like

No the leaderstats part worked just fine. If I open the UI then close it and try to re open it, it doesn’t work.

Edit: I also tried what you said and it doesn’t fix anything.

that is because you set visible to false. Instead, do this:

script.Parent.Visible = not script.Parent.Visible
1 Like

Thats the same to say false…

if its true, it will make it false, and if its false, it will make it true.

For both the close script and the person script? I doubt it will change anything but I will try.

wherever you change yourGuiHere.Visible to false, change it to yourGuiHere.Visible = not yourGuiHere.Visible

1 Like

It is the exact same as saying false. It doesn’t solve anything. Plus I even tried it and it doesn’t work.

if you copy in the raw code, i can fix it for you.

1 Like

local script

local boosted = script.Parent.Boosted
local regular = script.Parent.Regular
local vip = script.Parent.VIP
local close = script.Parent.Close
local regularTicket = game.ReplicatedStorage.Tickets.Regular
local boostedTicket = game.ReplicatedStorage.Tickets.Boosted
local plr = game.Players.LocalPlayer

boosted.MouseButton1Click:Connect(function()
	
end)

regular.MouseButton1Click:Connect(function()
	if plr.leaderstats.SneakyPoints.Value > 4 then
		plr.leaderstats.SneakyPoints.Value = plr.leaderstats.SneakyPoints.Value - 5
		local newTicket = regularTicket:Clone()
		newTicket.Parent = game.Workspace:FindFirstChild(plr.Name)
	end
end)

vip.MouseButton1Click:Connect(function()
	
end)

close.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
end)

script

local detector = script.Parent.ClickDetector

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	plr.PlayerGui.TicketUI.Frame.Visible = true
end)

put this all in the local script

local boosted = script.Parent.Boosted
local regular = script.Parent.Regular
local vip = script.Parent.VIP
local close = script.Parent.Close
local regularTicket = game.ReplicatedStorage.Tickets.Regular
local boostedTicket = game.ReplicatedStorage.Tickets.Boosted
local plr = game.Players.LocalPlayer
local detector = workspace.TicketGuy2.ClickDetector

boosted.MouseButton1Click:Connect(function()
	
end)

regular.MouseButton1Click:Connect(function()
	if plr.leaderstats.SneakyPoints.Value > 4 then
		plr.leaderstats.SneakyPoints.Value = plr.leaderstats.SneakyPoints.Value - 5
		local newTicket = regularTicket:Clone()
		newTicket.Parent = game.Workspace:FindFirstChild(plr.Name)
	end
end)

vip.MouseButton1Click:Connect(function()
	
end)

close.MouseButton1Click:Connect(function()
	script.Parent.Visible = false
end)

detector.MouseClick:Connect(function()
	script.Parent.Visible = true
end)