Okay so basically I need to be able to save vector 3 coordinates locally (I don’t Care how, just not through a Database) and then teleport the player back there. This is what I currently have (It’s not all of the script, but the rest is off topic)
local VectorToString = function(vec)
return vec.X..' '..vec.Y..' '..vec.Z
end
wait(0.1)
local vts = VectorToString(curpos)
wait(0.1)
plr:LoadCharacter(true) --The player died, respawn them.
playerworkspace.Head.Position = Vector3.new(vts)
In there it mentions ‘playerworkspace’ This is my vaariable for the player in the workspace. It works and I’ve tested it. ‘curpos’ Is a local variable that has the Vector3 location of the head before the reset. Any help is appreciated!
Userdata values (and by extension, Vector3Values) can’t be saved in a DataStore, so OP has to serialise it by turning it into a string that can be converted back and forth from String-Vector3 and vice versa. That’s what they’re attempting to do, but their implementation is, well, wrong.
I just typed a whole response but I’m a little confused by the thread’s content and archived it. What is it you’re trying to accomplish? Does your code not work, or is there another concern with your code?
I’m trying to keep a vector 3 value the same before i get respawned, so I can get teleported back to the point I was at before the respawn, then delete that vector 3 value.
Would it not be as simple as creating the value, setting it before a reset, setting the root back to that position after respawning and then just removing it?
There’s a couple of strange conventions here that I don’t quite understand. I think the implementation is fundamentally flawed and needs to be redone. What’s the specific use case you’re going for?
In terms of the conventions and whatnot that I don’t understand, they’re as follows:
What’s the purpose in fetching a player’s character via workspace[playerName]? There’s a property under a player, Character, that references their character.
I see what you’re trying to do in placing a character model in StarterPlayer and I want to tell you that this is not how you use StarterCharacter.
If you want to change a player’s character altogether, you have to manually implement a majority of the spawning procedures yourself.
You don’t need to create a Vector3 value here at all if it’s only a temporary value. You just need to hold the root’s position in a variable and set it back. The variable will get cleaned once it goes out of scope.
That being said, I’ve had a look through the post some (and noticed I misunderstood part of your post in that you aren’t looking to save via DataStore) but I’m not quite sure what your source of error is. Would you mind restating that so I can get a clear sense of what the issue is?
The community guide says to use this way of using a custom model other than using the script that changes it so I just went off that. I also have precautions for in case it fails.
When I create a variable that gets the player’s head position before the refresh, but whenever it respawns me, it updates the variable after I’m back at spawn.