I just wanted to know how do you make it work like this, if Player has touched Checkpoint1 and after touching Checkpoint2, the player can’t touch the Checkpoint1 and he doesn’t respawn on Checkpoint1 but on Checkpoint2.
Because I’ve been struggling for past few minutes and I don’t know how to make it work like this.
What have you got so far? That way we can help you make your code work.
Broadly speaking though, you’ll want to somehow check if the checkpoint that’s currently set is before the one that was just touched, and only set to the touched checkpoint of that’s the case.
-- This spawns the player on the correct point
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character) -- this will trigger after every death
repeat wait() until Player.Character
Player.Character:MoveTo(Spawns:FindFirstChild(Player.leaderstats.Stage.Value).Position)
end)
end)
-- this handles changing checkpoints. It only allows you to change if the next checkpoint is the very next one
for _, checkpoint in pairs(Spawns:GetChildren()) do
checkpoint.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local stage = Player.leaderstats.Stage.Value
if stage + 1 == tonumber(checkpoint.Name) then
Player.leaderstats.Stage.Value = stage + 1
end
end
end)
end
Player.leaderstats.Stage.Value – This assumes you will be saving data with datastores
All the spawns should be in a folder, and for simplicity the name is just numbered in order
The easiest way in my opinion is to simply add teams to your game, and make spawnpoints correlating for each time. Turn off neutral, and when they step on the spawnplate, their team value changes. No scripting required here.
How are you tracking the player’s current stage? The code I gave assumes that you’re using leaderstats, so you may need to change the occurrences of Player.leaderstats.Stage.Value to whatever you need to access the player’s stage.
In the script where you gave me, in “Player.Character:MoveTo(Spawns():FindFirstChild(Player.leaderstats.Stage.Value).Position)” and “for _, checkpoint in pairs(Spawns:GetChildren()) do” the “Spawns” is checked under with blue line, I don’t know what’s the issue
In the Spawnpoint’s properties, scroll down a little bit until you see this “teams” section.
Let’s say you make the “Level One” team. The Level One’s team color is “Maroon”. What you would do in this case is turn on AllowTeamChangeOnTouch, disable Neutral, and set the TeamColor to “Maroon”. From there, you only spawn on the plate if you are on that team, and you can join the team by touching the Spawnplate.
NOTE: Part.BrickColor =/= Part.TeamColor
Hope this helped.
Thank you for trying to help me with this issue, however I decided to use Roblox’s Checkpoint from Toolbox, and warn players to not go back to previous Checkpoints or else it’s their fault. Sorry for wasting your time, but seriously thank you for trying to help me!