Hi,
I am trying to figure out how to display in a ScreenGUI the local players X, Y, Z and update every 60 seconds but can’t figure out how to access the player’s position.
Julian
Hi,
I am trying to figure out how to display in a ScreenGUI the local players X, Y, Z and update every 60 seconds but can’t figure out how to access the player’s position.
Julian
Try getting the position from a body part of the player such as the HumanoidRootPart.
local Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
Make sure this is in a local script
I think you forgot to include the Character
property of the local player.
If the player’s character has loaded, game.Players.LocalPlayer.Character
will point to the player’s character model in the workspace.
Also @CanterCrow be aware that if the player has not spawned in yet, their Character
property will just be nil, so it would be a good idea to do some check before trying to access the character’s HumannoidRootPart.
You’re right, I made an edit. Thanks for the heads up.
thanks that has helped a lot but how do I get the X, Y & Z separately.
Julian
Ok I got it,
while true do
local player = game:GetService(“Players”).LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hmndrootpart = character:WaitForChild(“HumanoidRootPart”)
print("Pos X " .. hmndrootpart.Position.X)
print("Pos Y " .. hmndrootpart.Position.Y)
print("Pos Z " .. hmndrootpart.Position.Z)
wait(5)
end
Thanks for your help I have got working.