I have this code for a basic obby, but the second line errors out. Here's my code:
local spawnNum = tonumber(script.Parent.Name)
local prevSp = spawnNum - 1
script.Parent.Touched:connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:FindFirstChild(touch.Parent.Name)
if plr:WaitForChild("leaderstats").Stage.Value == prevSp then
plr:WaitForChild("leaderstats").Stage.Value = spawnNum
else
touch.Parent.Humanoid.Health = 0
end
end
end)
Errors out as: "attempt to perform arithmetic on local 'spawnNum' (a nil value)"

1 comment
Yes, my spawns are numbered.