I have a script that saves the X, Y and Z coordinates of players to a value in the player called X Y or Z
player.X.Value = workspace:FindFirstChild(player.Name).Torso.Position.Vector3.x player.Y.Value = workspace:FindFirstChild(player.Name).Torso.Position.Vector3.y player.Z.Value = workspace:FindFirstChild(player.Name).Torso.Position.Vector3.z
Now this doesn't work because Vector3 isn't a property of position, so how can I set the Vector3.z of the players torso to the value z?
Just create a Vector3Value and call it something like PlayerPosition
and then do the following to set the value (and make sure the player variable is the player):
player:WaitForChild("PlayerPosition").Value = player.Character:WaitForChild("Torso").Position --Waits for the Character's torso and the PlayerPosition Vector3Value in case they haven't loaded yet.
If you actually want it to save the value, so you can use it again when you join another server (let's say, for example, to respawn in the same place you left off at), use Data Stores
to save each sepearate axis value from the value of PlayerPosition
or use Data Persistence to save the actual PlayerPosition
value object or the object's value.
However, if you want to do it the way you're doing it, just use the x, y and z properties on Position, instead of adding .Vector3 after Position, like this:
player:WaitForChild("X").Value = player.Character:WaitForChild("Torso").Position.x player:WaitForChild("Y").Value = player.Character:WaitForChild("Torso").Position.y player:WaitForChild("Z").Value = player.Character:WaitForChild("Torso").Position.z --WaitForChild method used on all three lines, in case any of them aren't available instantly.