This is the error
ServerScriptStorage.ObbyHandler:25: attempt to index nil with 'leaderstats'
This is the script
local obbyStages = workspace:WaitForChild("ObbyStages")
for _,stage in pairs(obbyStages:GetChildren()) do
stage.Touched:connect(function(hit)
local hum
if hit.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Humanoid
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
end
end)
end

3 comments
plr is nil because something other than a player touched it
Ahhhhhh
How can I fix that