So I’m making an Obby and when you join the game or die then you spawn on a random one. How can I fix it so you spawn on the last on you touched or when you join the game you spawn at the start?
Hey there, first, I think this post should be in the category scripting Support.
Second, did you use any “Obby Kits“ or are you just using normal spawn Parts?
I just used normal spawns. I am trying not to use any toolbox items because I want to make it look like I actually worked hard on this like I am. No offense to anyone who does its just personal preference.
Normal spawns are going to make you spawn at any of them
Ok how can I get it like I said above?
You could save what stage the player was last on then when the player dies or spawns it teleports to that last part or something, maybe there are better ways out there
I’ll try that. Just to make sure, I would do this by using a DataStore, and saving the players position? Or the stage like you said.
I would say the stage if you sometime in the future decide to change something. So just make a touch part when the stage starts then put either the position of that start or maybe a stage number into a value that you then can use to teleport the player.
Ok thanks for verifying I’ll try that and see if it works.
are you referring to checkpoints?
Yes that’s what I meant sorry.
Here is one script:
spawn.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Model", game.ServerStorage)
checkpointData.Name = "CheckpointData"
end
local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
if not checkpoint then
checkpoint = Instance.new("ObjectValue", checkpointData)
checkpoint.Name = tostring(player.userId)
player.CharacterAdded:connect(function(character)
wait()
character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end)
end
checkpoint.Value = spawn
end
end)
I tried this and it didn’t work, I put it in ServerStorage as a script. Did I do something wrong?
just make a script [ in the part ] and copy paste this over there
function onCheckpointTouched(plr : Player, checkpoint : SpawnLocation)
plr.RespawnLocation = checkpoint;
end
This will make them respawn at whichever spawn location the RespawnLocation
property is set to.