Hello!

So in my game I need to check if the player is a certain distance away from a part to display a gui, but the problem is, checking the distance from the part isn't working and no errors are showing up in the output. Here's my localscript.

local distance = workspace.distance
 
local player = game.Players.LocalPlayer
local part1 = player.Character.Fedora
 
local part2 = workspace["Aseroid Groups"].Model.AsteroidNotice
 
while wait() do
    local magnitude = (part1.Position - part2.Position).magnitude
    distance.Value = part2.Name.." is "..math.floor(magnitude).." studs away."
	--print(distance)
end

I apologize if my code is unorganized or if the error is obvious...I didn't get much sleep last night. Also please don't bug me about the spelling error on line 6 );

Thanks!

-GreenGrassGamer2008

2 comments

0

add a wait(1) at the top to let the character load, make sure its in a local script, also make sure distance is a string value and every thing should work.

0

still didn't work. weird