Hello. I am trying to make a shop in my game. I made it so that when you touch a part, it opens a button which can open the shop. But if I step off that part, the button remains there. I know I can create a button to close the shop, but I want the players to be able to buy from the shop only if they are inside the shop. So, I need someone to help me with this. I want to do it like when they step off that part, the button dissapears, without having to click a separate button. If you know a way of doing it, please tell me. Thanks!
part.TouchEnded:Connect(function(part) -- leaves the part if game.Players:GetPlayerFromCharacter(part.Parent) then -- if the part leaving is a player plr = game.Players:GetPlayerFromCharacter(part.Parent) -- the player if plr.PlayerGui:FindFirstChild("Gui") then -- if the gui is open plr.PlayerGui:FindFirstChild("Gui"):Destroy() -- destroy the gui end end end)