Hello gentle man i need help in this script the mob should spawn at the start that is a part
at the start there are no problem but close to wave 4 the game breaks and give me this error:
ServerScriptService.Main.Mob:31: attempt to index nil with ‘Start’
and i don’t know what to do i try many things but they all gave me the same error if you want the wave script here you go
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
this is the first code is a module script
local ServerStorage = game:GetService("ServerStorage")
local PhysicService = game:GetService("PhysicsService")
local ServerStorage = game:GetService("ServerStorage")
local bindables = ServerStorage:WaitForChild("Bindables")
local updateBaseHealthEvent = bindables:WaitForChild("UpdateBaseHealth")
local mob = {}
function mob.Move(mob, map)
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = map.Waypoints
for waypoint=1, #waypoints:GetChildren() do
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait()
end
mob:Destroy()
updateBaseHealthEvent:Fire(humanoid.Health)
end
function mob.Spawn(name, quantity, map)
local mobExist = ServerStorage.Mobs:FindFirstChild(name)
if mobExist then
for i=1, quantity do
task.wait(0.5)
local newMob = mobExist:Clone()
newMob.HumanoidRootPart.CFrame = map.Start.CFrame
newMob.Parent = workspace.Mobs
newMob.HumanoidRootPart:SetNetworkOwner(nil)
for i, object in ipairs(newMob:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Mob"
end
end
newMob.Humanoid.Died:Connect(function()
task.wait(0.5)
newMob:Destroy()
end)
coroutine.wrap(mob.Move)(newMob, map)
end
else
warn("Request mob does NOT exist!", name)
end
end
return mob
the main script with the wave sistem that request all the module script
local ServerStorage = game:GetService("ServerStorage")
local bindables = ServerStorage:WaitForChild("Bindables")
local gameOverEvent = bindables:WaitForChild("GameOver")
local base = require(script.Base)
local mob = require(script.Mob)
local tower = require(script.Tower)
local map = workspace.SplitPath
local gameOver = false
base.SetUp(map, 500)
gameOverEvent.Event:Connect(function()
gameOver = true
end)
for wave=1, 30 do
print("WAVE STARTING:", wave)
if wave < 3 then
mob.Spawn("Mutant", 3 + wave, map)
elseif wave == 3 then
mob.Spawn("Sprinter", 5, map)
mob.Spawn("Mutant", 5, map)
elseif wave < 8 then
mob.Spawn("Sprinter", 5 + wave, map)
mob.Spawn("Mutant", 5 + wave)
elseif wave == 8 then
mob.Spawn("Sprinter", 5 + wave, map)
mob.Spawn("Mutant", 5 + wave)
mob.Spawn("Sponge", 7 , map)
elseif wave < 12 then
mob.Spawn("Sprinter", 5 + wave, map)
mob.Spawn("Mutant", 5 + wave)
mob.Spawn("Sponge", 1 + wave , map)
elseif wave == 12 then
mob.Spawn("Sprinter", 15, map)
mob.Spawn("Mutant", 20, map)
mob.Spawn("Sponge", 10, map)
mob.Spawn("Monster", 1, map)
end
repeat
task.wait(1)
until #workspace.Mobs:GetChildren() == 0 or gameOver
if gameOver then
print("GAME OVER YOUR A NOOB!")
break
end
print("WAVE ENDED")
task.wait(1)
end
if you can find the solution or a possible solution i’ll be happy to hear it
have a nice day