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

How could I go about making a GUI close when you walk away? [closed]

Asked by 4 years ago

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.

1
Keep checking the distance between the click detector part and the player's torso (minus their positions and then Vector3.Magnitude) if the distance is greater than let's say 20 studs then find the Gui in the player and destroy it. radiant_Light203 1166 — 4y
0
Could you post your script, so we can see where you went wrong and it's easier for us to help you? killerbrenden 1537 — 4y
0
Use magnitude. AntiWorldliness 868 — 4y

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?

2 answers

Log in to vote
0
Answered by 4 years ago

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.

0
RenderStepped is Client-Sided, so you might want to change it to RunServer.Stepped:Connect(function(). killerbrenden 1537 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

When a player steps on a part the GUI comes When a player steps on another GUI when it leaves