How to make the character spawn at the right checkpoint

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Im making an obby and what i want is a the player to spawn at the checkpoint if they had touched it.
  2. What is the issue? Include screenshots / videos if possible!
    Sometimes it would spawn them back at the start.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to change the location of them thinking that would work, but it now seems to happen on any checkpoint where it would be rare to spawn at the start thus losing all progress.
    So if anyone knows how to fix it reply!
    Thanks for reading!
    EDIT: i am using default spawn points!
1 Like

uh what…i dont understand (im new to scripting and dont yet understand XD)

1 Like

Here is how I made a checkpoint System, First organize your files like this:
image
I named the checkpoints a number so if you clone a checkpoint name it 2, next one is 3 and so on.

Inside of the checkpoint put this in a script:

script.Parent.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChild("Humanoid")
	
	if hum then
		local player = game.Players:FindFirstChild(hum.Parent.Name)
		
		if player then
			local stats = player:FindFirstChild("leaderstats")
			
			if stats then
				local checkp = stats:FindFirstChild("Checkpoint")
				
				if checkp then
					if checkp.Value == (script.Parent.Name - 1) then
						checkp.Value = checkp.Value + 1
					end
				end
			end
		end
	end
end)

Then in leaderboard do this:

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

	local Checkpoint = Instance.new("IntValue")
    Checkpoint.Name = "Checkpoint"
    Checkpoint.Parent = leaderstats
end)

Finally you need a script that checks where the player needs to spawn, and for that make a script here:image

And put this code in the script:

local char = script.Parent

local player = game.Players:FindFirstChild(char.Name)

repeat wait() until player.leaderstats
repeat wait() until player.leaderstats.Checkpoint

local findspawn = game.Workspace.SpawnSystem.Checkpoints:FindFirstChild(player.leaderstats.Checkpoint.Value)

if findspawn ~= nil then
	char.Torso.CFrame = findspawn.CFrame * CFrame.new(0,5,0)
end
4 Likes

Why not you use teams and spawns for the checkpoints? It is a lot more simpler

1 Like

2 Methods I can think of:

Create a leaderstat that changes when the next checkpoint is touched, and set the player’s spawnlocation to the checkpoint number. (Harder than method 2 but takes less time)

Create teams and set the player to a new team for every spawn touched. (Easier but weaker against exploiters)

Also check this out https://education.roblox.com/en-us/resources/intro-to-studio-checkpoints

2 Likes

I dont want the teams showing up on the side, there are alot of levels

1 Like

Thanks for such a detailed response i got it working. Thank You

2 Likes

Ok so i found this…sometimes i would spawn at the start even after being at checkpoint 4 (not supposed to happen) and also the leaderstats wouldn’t always show up im not sure why, but if i rejoin it appears again!?
Edit i have added 30 checkpoints so maybe that broke something i dont know

1 Like

Use teams instead and make sure that “Neutral” is false and “AllowTeamChangeOnTouch” is enabled.
Then, when the player touches the spawnlocation, they are automatically teamed to the team colour that they touched and when they die they re-spawn back at the last spawnlocation the player touched.

robloxapp-20200814-0854485.wmv (5.4 MB)

Quality is not the best…

1 Like

hello, ah as i said in a previous reply

So adding teams would be a mess to the side

1 Like

You don’t have to have the teams showing on the side. If you watch my video you can see that there are no teams showing on the playerlist.

1 Like

Is there a way to hide them? if there is i will consider them.

1 Like

They are already hidden, watch the video.

1 Like

i have watched it, did you hide it or was it already hidden?

1 Like

Teams are automatically hidden unless you insert a team module into the teams folder.

I have not included any team modules just spawn locations.

1 Like

ok ill see how it goes
30charssss

1 Like

Ah i forgot to mention why i didn’t want teams i also want leaderstats showing what level you are up to, can you add them to the teams?

1 Like

I dont understand what you mean. Are you wanting players to be able to see what level other players are?

1 Like

Yes
30charssssssssssssssssssssssssss

1 Like

If you want other players to see what part of the obby players are on then you could just add team modules and number them in sync with the spawn locations, this will then however show up on the player list which you don’t want it to do so.

1 Like