GUI closes but won't come back on touch?

I’m trying to make a button that closes the GUI when clicked and it closes it, but it also makes it unable to be opened again.

So the GUI is cloned from ServerStorage into a player’s PlayerGui:

SpawnGiver

script.Parent.Touched:connect(function(p) --Edit: <–That’s a p) not sure why it’s showing that weird symbol.
local player = game.Players:GetPlayerFromCharacter(p.Parent)
if (player) then
if (not player.PlayerGui:FindFirstChild(“SpawnGUI”)) then
local GUI = game:GetService(“ServerStorage”).SpawnGUI:Clone()
GUI.Regen.Value = script.Parent.Parent.Pos
GUI.Parent = player.PlayerGui
end
end
end)

This is in my script for when my button is clicked:

SpawnGUILocal

bg.X.MouseButton1Click:connect(function()

player.PlayerGui.SpawnGUI:Destroy()

end)

I want the GUI to be able to pop up again when someone touches the pad.
Thoughts?

2 Likes
3 Likes

Thanks, but what can I do to replace this system then?

Please put your code in a code block

1 Like

I would probably keep all UI manipulation on the client, and handle actions that require security checks with remotes.

I would recommend making the GUI completely client-sided with any outside functionality that requires client-server communication redirecting to RemoteEvents or RemoteFunctions.

You could also have a server-sided script inside the close button that can close the GUI, as server-sided scripts can also handle mouse button inputs (i.e. MouseButton1Down), though I don’t recommend this as much.

1 Like