Is :DistanceFromCharacter() broken?

I’m making an scp-gengre game and stumbled on issue with DistanceFromCharacter function returning 0 instead of real numbers. But magnitude method is working fine


The issues is that before that function wasnt broken before and now I’m forced to rescript half of all code. Is there any chance for it to be fixed?

1 Like

No, it’s not broken. It returns 0 if player’s character is not there. And it get’s distance from the character’s head, hence the slight difference compared to primary part magnitude.

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()


I also suggest you initially check whether character and its primary part exist before attempting to index position of a killer and a target.


Oh, issue was that my characters have no heads, not a single word about it anywhere, thank you for information.

1 Like

Lol, I wasn’t completely sure why it didn’t work in your case (suspecting some tricky parameter issue or so), but definitely wasn’t expecting missing heads! :rofl:

No problem and good luck with your project!

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