JamswrId
(Jam)
#1
Error:
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
JamswrId
(Jam)
#4
I have all the checkpoints in a folder.
centau_ri
(centauri)
#6
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))
Change that quoted line to
local checkpoint = workspace.Checkpoints:FindFirstChild(Checkpoint.Value)
I didn’t notice you were using .
instead of :
for FindFirstChild
JamswrId
(Jam)
#10
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