Checkpoint Help Error

Error:
image

I am trying to make a checkpoint system. The code has an error which I do not know how to fix.

game.Player.PlayerAdded:Connect(function(Player)
	local leaderstats = Instance.new("Folder",Player)
	leaderstats.Name = "Leaderstats"
	
	local Checkpoint = Instance.new("IntValue", leaderstats)
	Checkpoint.Name = "Checkpoint"
	Checkpoint.Value = 0
	
	Player.CharacterAdded:Connect(function(Character)
		repeat wait() until Player.Character ~= nil
		local checkpoint = workspace.Checkpoints.FindFirstChjild(Checkpoint.Value)
		Character:WaitFOrChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position +Vector3.new(0,2,0)
	end)
end)

You made a few typos such as FindFirstChjild and game.Player, but basically you forgot to close the CFrame.new

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local leaderstats = Instance.new("Folder",Player)
	leaderstats.Name = "Leaderstats"

	local Checkpoint = Instance.new("IntValue", leaderstats)
	Checkpoint.Name = "Checkpoint"
	Checkpoint.Value = 0

	Player.CharacterAdded:Connect(function(Character)
		local checkpoint = workspace.Checkpoints:FindFirstChild(Checkpoint.Value)
		Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,2,0))
	end)
end)
2 Likes


Still the same error

I have all the checkpoints in a folder.

image

You’re missing a parenthesis at the end of line 11.

Add a ) at the end of line 11, I added that in the code block I’ve provided

Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(checkpoint.Position + Vector3.new(0,2,0))

image
It just showed this

Change that quoted line to

local checkpoint = workspace.Checkpoints:FindFirstChild(Checkpoint.Value)

I didn’t notice you were using . instead of : for FindFirstChild

There is no error code now thanks.

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

2 Likes