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.

23 Likes

BasePart | Documentation - Roblox Creator Hub

3 Likes

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.

40 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.

11 Likes

Thank you, it works for finding the player position.

1 Like