Gui won't show again after one time of opening and closing

I don’t know why but I have a server script that locates the playergui and enables a gui to show but it doesn’t seem to work after once time of opening closing it.
This is the server script to open it :

	local Gui = player:WaitForChild("PlayerGui").ShopGuis.GersonShop
	Gui.Enabled = true
	Gui.Frame.Shop.Text.Visible = true
	Gui.Frame.Shop.Text2.Visible = true
	Gui.Frame.Shop.Text3.Visible = false
	Gui.Frame.Shop.Text.Text.Script.Disabled = false
	Gui.Frame.Shop.Text2.Text.Script.Disabled = false
	Gui.Frame.ShopItems.Visible = false
	Gui.Frame.ShopItemsDisplay.Visible = false
	Gui.Frame.Options.Visible = true
	Gui.Frame.Shop.Visible = true

This is the local script to close it :

local closebutton = script.Parent
local Gui = script.Parent.Parent.Parent.Parent
local Players = game:GetService("Players")

local client = Players.LocalPlayer

local char = client.Character or client.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")

	Gui.Frame.Shop.Text.Text.Script.Disabled = true
	Gui.Frame.Shop.Text.Text.Text = ""
	Gui.Frame.Shop.Text.Visible = false
	Gui.Frame.Shop.Text2.Text.Script.Disabled = true
	Gui.Frame.Shop.Text2.Text.Text = ""
	Gui.Frame.Shop.Text2.Visible = false
	Gui.Frame.Shop.Text3.Text.Script.Disabled = true
	Gui.Frame.Shop.Text3.Text.Text = ""
	Gui.Frame.Shop.Text3.Visible = false
	Gui.Frame.Options.Visible = false
	Gui.Frame.Shop.Text4.Text.Text = ""
	Gui.Frame.Shop.Text4.Visible = true
	Gui.Frame.Shop.Text4.Text.Script.Disabled = false
	Gui.Frame.Shop.Text4.Text.Script.Disabled = true
	Gui.Frame.Shop.Text4.Text.Text = ""
	Gui.Frame.Shop.Text4.Visible = false
	Gui.Enabled = false
	h.WalkSpeed = 40
	h.JumpPower = 40

Help would be appreciated thank you!

I assume it’s because on the client you’re doing the opposite operations, and as we know -
The server won’t see those changes, hence, this is the reason I can think of causing this issue.

Try to use a remote to make sure the server would recognize those changes and work along with the script in the server

1 Like

May I ask why the open and close scripts are in two different scripts?

1 Like

Cause one is a serverscript so it can connect to a proximityprompt? And the other is a local script stored in the gui which closes the gui?
I’ve sorted the problem anyway by making a localscript that can detect the proximityprompt

Oh wait sorry I didn’t see the Proximity Prompt properly

The issue is caused because you’re opening the gui from the server and closing it from the client, the former action replicates across the client-server boundary, the latter does not, as such from the server’s perspective the gui is ‘open’ even if it has been closed by the client. You can remedy this in an improper way by having the server toggle the gui’s closed/open state, i.e;

gui.Enabled = false --set to false on server before switching back to true
gui.Enabled = true

The correct way would be to have the server fire the client via a RemoteEvent (when the prompt is triggered) and to have the client ‘open’ the gui, that way the client handles both the closing and opening of the gui (replication is no longer an issue).