So I have a script that makes a GUI Pop up when you press a dialogue
the problem was that I wanted the GUI dissapear when the player is too far from the dialogue
is there any way?
01 | -- // Local script |
02 | local plr = game.Players.LocalPlayer |
03 | local part = -- // Target part |
04 | local max = -- // Max distance |
05 | local dialogue = -- // Dialog |
06 | while wait() do |
07 | if (plr.Character.HumanoidRootPart.Position - part.Position).magnitude < = max then |
08 | dialogue.Visible = true |
09 | else |
10 | dialogue.Visible = false |
11 | end |
12 | end |
This should work.