I used a tutorial from squidingz to make an obby checkpoint system but I don’t understand line 6. Can anyone explain that to me? Is it checking if the humanoidrootpart exists?
--Datastore variables
local DSS = game:GetService("DataStoreService")
local datastore = DSS:GetDataStore("DataStore")
function plrtostage(plr)
repeat wait() until plr.Character.HumanoidRootPart
local stagepart = game.Workspace.Checkpoints:FindFirstChild(tostring(plr.leaderstats.Checkpoint.Value))
plr.Character.HumanoidRootPart.CFrame = stagepart.CFrame + Vector3.new(0,2.5,0)
end
--Leaderboard
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local checkpoint = Instance.new("IntValue", folder)
checkpoint.Name = "Checkpoint"
local success, errormessage = pcall(function()
checkpoint.Value = datastore:GetAsync(plr.UserId)
end)
if success then
print("Success")
else
print("Error")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
datastore:SetAsync(plr.UserId, plr.leaderstats.Checkpoint.Value)
end)
if success then
print("Saved")
else
print("Error")
warn(errormessage)
end
plr.CharacterAdded:Connect(function()
plrtostage(plr)
end)
end)
for i,v in pairs(game.Workspace.Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local cnumber = tonumber(v.Name)
if player.leaderstats.Checkpoint.Value < cnumber then
player.leaderstats.Checkpoint.Value = cnumber
end
end
end)
end