Im getting this error
Workspace.Checkpoints.Script:10: invalid argument #3 (CFrame expected, got number) - Server - Script:10
local Checkpoints = script.Parent
for i,v in pairs(Checkpoints:GetChildren())do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player.leaderstats.Stage.Value < tonumber(v.Name) then
player.Character.HumanoidRootPart.CFrame = tonumber(player.leaderstats.Stage.Value)
end
end
end
end)
end
end
You’re setting CFrame to a number, what are you trying to do? If you’re trying to teleport the player to their current stage, then you need to get the Checkpoint part and then set the CFrame to the checkpoint’s CFrame
1 Like
Like how the checkpoint folder is located in workspace it has every single checkpoint in it as of values
like
1
2
3
etc
You will need to get the position of the checkpoint.
1 Like
You’re not getting them at all, You need to get the checkpoint and teleport them there
Getting the part should be simple
Checkpoints[tostring(player.leaderstats.Stage.Value)]
Then you just get the CFRame
Checkpoints[tostring(player.leaderstats.Stage.Value)].CFrame
Then set that to the CFrame
player.Character.HumanoidRootPart.CFrame = Checkpoints[tostring(player.leaderstats.Stage.Value)].CFrame
1 Like
Now everytime i touch a checkpoint it teleport me back to the last checkpoint
What were you trying to do then? I didn’t understand what had to be done
I’m making a checkpoint system
Yes, but what were you trying to do in this line?
As in, what were you expecting to happen?
I don’t mean anything i just want it to add a value to his stage in leaderstats like checkpoint system
Do you mean changing the stage value to the current stage’s name? If so
player.leaderstats.Stage.Value = tonumber(v.Name)
1 Like
Thank you just one little thing
Why this script makes him stuck when he get TP’d
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
player.Character.HumanoidRootPart.CFrame = Checkpoints[tostring(player.leaderstats.Stage.Value)].CFrame
It’s probably the way the code is organized, by stuck, do you mean constantly teleporting or stuck in the ground?
He get teleported and he get stuck in the ground at the checkpoint he teleported to
Oh that’s imple, just offset the CFrame by 3 studs
Change this
player.Character.HumanoidRootPart.CFrame = Checkpoints[tostring(player.leaderstats.Stage.Value)].CFrame
To this
player.Character.HumanoidRootPart.CFrame = Checkpoints[tostring(player.leaderstats.Stage.Value)].CFrame * CFrame.new(0, 3, 0)
1 Like
Thank you so much I really appreciate everything 
1 Like