Distance is 0 on spawn

when the player spawns they are “0” studs away from the part no matter where the part is.

while task.wait(0.1) do
	
	for _, checkPlayer in pairs(game.Players:GetChildren()) do
		if checkPlayer then
			player = checkPlayer
		end

	end
	
	if player then
		local first_Distance = player:DistanceFromCharacter(game.Workspace.Part.Position)
		print(first_Distance)
	end

end

How do I get around that? A player could spawn at any time.

I’m not really sure what you’re trying to achieve here but maybe Players.PlayerAdded might help.

Thank you again for your help.

Players.PlayerAdded was not what I needed but the thought was. So I used:

if checkPlayer.Character then

to get the same result.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.