You can write your topic however you want, but you need to answer these questions:
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.
What is the issue? Include screenshots / videos if possible!
Sometimes it would spawn them back at the start.
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!
Here is how I made a checkpoint System, First organize your files like this:
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:
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
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)
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
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.
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.