Can someone tell me how to fix this script? I keep getting the error:
attempt to get length of upvalue 'TotalSpawns' (a number value)
Code:
local TotalSpawns = 0 for _,v in pairs(script.Parent.Spawns:GetChildren()) do if v:IsA("Part") then TotalSpawns = TotalSpawns + 1 print("Total Spawns: "..TotalSpawns) end end for _,v in pairs(script.Parent.Lava:GetChildren()) do v.Touched:connect(function(touch) if touch.Parent:FindFirstChild("Humanoid") then local ran = math.random(1,#TotalSpawns) touch.Parent.HumanoidRootPart.CFrame = script.Parent.Spawns:FindFirstChild("Spawn"..ran).CFrame end end) end