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

Data Storing the Players Position?

I've been using a work around to "You can't save Vector3's to DataStore," by saving each axis, However the results are...Not pretty.

Instead of the X, Y, and Z Coords, I get 1.2714055432228943e-023,2.9659440517425537,-1.6159910306761053e-023. Which makes sense, there are 3 of them, just...Very wrong coordinates!

When Saving

local pos = Instance.new("Vector3Value")
		pos.Value = Player.Character.Torso.Position
		local savePoint = {Player.leaderstats.Money.Value, Player.leaderstats.Allegiance.Value, 
		Player.leaderstats.Level.Value, Player.Class.Value, pos.Value.X, pos.Value.Y, pos.Value.Z}
		local saveString = Utils:JSONEncode(savePoint)
		save:SetAsync("sav_" .. Player.Name, saveString)

and then it loads it, Decodes it from JSON to table, and Moves the player based on the last 3 Values.

To be blunt, It doesn't do that...

1 comment

0

Cant you just create 3 number variables for each axis and then when loading put those variables into the player's position

1 answer

✓ Accepted answer

You could just make a datastore with the values separate, with no JSON stuff needed...

local Vector3Store = game:GetService("DataStoreService"):GetDataStore("Vector3Store") --Or whatever it is, I can't remember this late at night

Vector3Store:SetAsync("X", n)
Vector3Store:SetAsync("Y", n2)
Vector3Store:SetAsync("Z", n3)

Then, you call this entire thing up as a table, no JSON needed, and voila.

1 comment

0

True point, I got this working (Somehow, I'm not quite sure of it) but I'll give you the credit as this method also worked.

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