Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can I somehow close a popup gui when i step of a brick?

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!

2 comments

0

Touchended?

0

yes its possible

1 answer

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)

2 comments

0

You do not want to destroy a GUI. Just set the GUI's enabled to false

0

You should indent your scripting .-.

This discussion is preserved as it was. New answers, comments, and votes are closed.