Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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!

0
Touchended? User#20388 0 — 6y
0
yes its possible awesomeipod 607 — 6y

1 answer

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
6 years ago
Edited 6 years ago
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)
0
You do not want to destroy a GUI. Just set the GUI's enabled to false Axceed_Xlr 380 — 6y
0
You should indent your scripting .-. Crazycat4360 115 — 6y
Ad

Answer this question