Hello, everyone! I’m trying to make a checkpoint system, but I keep getting this error:
The script works just fine, but I keep getting that error which is very annoying.
My script:
for i,v in pairs(game.Workspace.Checkpoints:GetChildren()) do
local new = script.Spawn:Clone()
new.CFrame = v.CFrame
new.Parent = v
end
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
plr.RespawnLocation = game.Workspace.Checkpoints["1"]:WaitForChild("Spawn")
char:WaitForChild("Humanoid"):LoadCharacter()
local Lstats = Instance.new("Folder",plr)
Lstats.Name = "leaderstats"
local stageVal = Instance.new("IntValue",Lstats)
stageVal.Name = "Stage"
for i,v in pairs(game.Workspace.Checkpoints:GetChildren()) do
v.Touched:Connect(function()
if v.Parent:FindFirstChild("Humanoid") then
if v.Parent.Name == plr.Name then
stageVal.Value = v.Name
end
end
end)
end
end)
I haven’t finished this script yet, but if you see anything else that looks off. Let me know!
Thanks, everyone!