Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

DistanceFromCharacter not working like it is supposed to?

while true do 
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        print(player:DistanceFromCharacter(Vector3.new(workspace.Part.Position)))
    end
    wait(0.1) 
end

Whenever I join the game, and move the brick, nothing changes. When I walk, the position is fixed to a fixed point I believe, that is not the brick.

3 comments

0

dude just find it the normal way

0

Show me the "normal way". As far as I know, this is the only way.

1

Maybe your error comes from the way you used the Vector3 constructor? The part’s position is already a Vector3, you don’t need to use a Vector3.new(). Try DistanceFromCharacter(workspace.Part.Position)

1 answer

Try it without the vector3 constructor, and also remember that fe means that the client's changes do not replicate to the server, if you are using a local script to move the brick that may be the cause.

while true do 
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        print(player:DistanceFromCharacter(workspace.Part.Position))
    end
    wait(0.1) 
end

This discussion is preserved as it was. New answers, comments, and votes are closed.