Finding a player's position

How does one find a player’s position? I’m trying to find a player’s humanoid root part position, but I don’t know how. Any help on this is appreciated.

16 Likes

https://developer.roblox.com/en-us/api-reference/property/BasePart/Position

1 Like

You can find their position by doing

game.Players.PlayerName.Character.HumanoidRootPart.Position

However, this could error if Character or HumanoidRootPart isn’t there. Ideally you would want to do something more like

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
		while humanoidRootPart do
			print(player.Name,"is at",tostring(humanoidRootPart.Position))
			wait(4)
		end
	end)
end)

This would print the player’s position every 4 seconds.

38 Likes
-- access the character though any one of the several ways available
local char = player.Character or player.CharacterAdded:Wait()-- as an example
local pos = char:GetPrimaryPartCFrame().p -- the root part is the primary part for the character model

By the way, calling tostring on the position isn’t necessary, you can print a Vector3 value normally.

8 Likes

Thank you, it works for finding the player position.

1 Like