I have a script that calculates magnitude(distance between objects) and it makes my GUI visible when I spawn in. It needs to be visible but not when I spawn, its supposed to appear when I am 10 or less studs away. How can I make it appear only when I am 10 or less studs away? Any and all help is appreciated.
Distance = 0
GetFirstDistance = false
GetSecondDistance = false
GetThirdDistance = false
Player = game:GetService("Players").LocalPlayer
function GetDistance(ObjOne, ObjTwo)
for i = 1,1 do
Distance = math.ceil((ObjOne.Position - ObjTwo.Position).Magnitude)
script.Parent.Distance.Text = Distance
end
end
while true do
if Distance <= 10 and GetFirstDistance == false then
script.Parent.Interact.Visible = true
end
GetDistance(Player.Character.Torso, workspace.PrologueObjPoints.ObjOne)
wait(0.25)
end

1 comment
this wont work as the distance is still less than 10 and the getfirstdistance is false, meaning the gui will show no matter what