I have a click detector to open it and a text button to close it but I want it to close when you walk a certain distance away so people can't keep the GUI open for using it to their advantage.
Find the Part that makes the gui open and find the player's HumanoidRootPart.
Next Find RunService using
local RunService = game:GetService("RunService")
Now run this function which uses magnitude to find the distance between the player and the part.
RunService.RenderStepped:Connect(function() if (GuiPart.Position - HumanoidRootPart.Position).Magnitude < 15 then Gui.Visible = true else Gui.Visible = false end end)
Feel free to change the 15 to something lower or higher.
When a player steps on a part the GUI comes When a player steps on another GUI when it leaves
Closed as Not Constructive by WideSteal321, Nguyenlegiahung, JesseSong, jediplocoon, TaxesArentAwesome, and killerbrenden
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?