I made a shop gui and it works and all, but when i tried making the part that opens it when you touch it, it works only one time. After i close it and try to open the gui again, it does nothing. I have no idea why. this is the script of the part to open the gui:
debounce = false script.Parent.Touched:Connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr and debounce == false then debounce = true plr.leaderstats.Coins.Value = 10 plr.PlayerGui.ScreenGui.Shopkeepa.Visible = true debounce = false end end)
Put this in a server script as a child of the part you want the player to touch
script.Parent.Touched:Connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) local Gui = Player.PlayerGui.ScreenGui.Shopkeepa repeat wait() until game.Players:GetPlayerFromCharacter(hit.Parent) while wait() do for i, v in pairs(game.Players:GetChildren()) do if (v.Character.Head.Position - script.Parent.Position).magnitude <= 5 then Gui.Visible = true else Gui.Visible = false end end end end)