When I test my game, the shop GUI will pop up when I touch the shop part at the first time but after closing the shop with the close button and touch the shop part again, the shop won’t pop up. The followings are the codes and screenshot of the explorer tab of the game:
Organisation of the game
Shop GUI
Shop part
Shop part script
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game:GetService("Players"):FindFirstChild(hit.Parent.Name).PlayerGui.GUIS.Shop.Visible = true
end
end)
wait(0.1)
end````
Close GUI script
local shop = script.Parent.Parent
local function close()
shop.Visible = false
end
button.MouseButton1Down:Connect(close)````
HideOnGameStart script
script.Parent.Visible = false
Sorry if it is a simple mistake as I am a beginner in scripting
You would use the RemoteEvent to open the UI on the client instead of on the server. That way when you close it, the client knows that the UI element is indeed visible (and vice versa).
Just noticed the page I linked in my reply might not’ve worked at first - it has examples:
The general philosophy is that you fire a RemoteEvent on the server to the player who touched the shop area. On the client, you check for the event of that RemoteEvent firing and trigger a function to open the shop UI.