1. What do you want to achieve? Keep it simple and clear!
I want players to be able to teleport to the last checkpoint they achieved in my obby but only for their current game session.
ie they die in a lava zone but they can quickly teleport back there again to try and pass the level or they can do something else (the obby is just an extra feature hence I don’t want them to spawn there using the teams obby method.)
2. What is the issue? Include screenshots / videos if possible!
If I parent the last touched checkpoint’s ObjectValue / location to the player then data gets deleted when they reset / die. So if the player dies on a lava stage then they attempt to teleport to their last checkpoint they don’t have it parented to them anymore so there is no way I can teleport them back.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve looked into Datastores but I feel like this may be too much as I only want to save a single location for a players current game session. Datastores are typically used when data should persist between game sessions. So I don’t think I need them but I’m not sure.
I have a feeling there is somewhere else I should parent this data so that it does not “die” / get erased, when the player dies.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
My data is always saved if the player doesn’t die. When they do, the last checkpoint data is cleared as it is an ObjectValue location parented to the player. I don’t know how to stop this.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Thanks for reading I’d appreciate any suggestions!
Thanks for your reply Isaac, I’m glad you said I don’t need DataStores.
Sorry, I’m quite new to this. I’ve only ever parented values and data to players or DataStores before. This is what my checkpoint does at the moment when a player touches it.
checkpoints.Touched:Connect(function(part) – Fires if Checkpoint Part Is Touched
print("New Checkpoint Touched")
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then -- Checking if a player touched the checkpoint part
local PlayerCheckpoint = humanoid.Parent:FindFirstChild("ObjectValue") -- Finding the object value in the player's character
print("Object Value Found")
if not PlayerCheckpoint then return end -- check if player has an object value in their character to prevent error messages
PlayerCheckpoint.Value = checkpoints -- assigning the value of ObjectValue to the checkpoint part.
end
end)
If I was to save the checkpoint location to a server side variable could you please explain how I would make it unique for every player? I’ve never done this before.
Using my current (broken) method I can fetch the data parented within each player when they touch my obby teleporter.
I’m not sure how to save it to a variable in the server and retrieve it again. Are there any examples like this I can look up? I’ve been using the Dev Hub a lot but haven’t found anything about this yet.
Thanks for your reply Abcreator, I think I’ve tried this but when I parented the checkpoint value to the player it got deleted when the player reset or died.
At the moment using Isaac’s advice I’ve created a new folder in workspace to store everyone’s last checkpoint position.
However I’m not yet sure how I will retrieve this information correctly when a player touches the obby teleporter. I’m going to read up about how to save these locations with a player name so that the players don’t go to each others checkpoints.