I have got errors in my code and i cannot fix it

Code just stopped working for no reason
I got the errors

On my main script
ServerScriptStorage.Main.Mob:29: Expected identifier when parsing expression. got ‘then’
Here is my main script

local PhysicsService = game:GetService("PhysicsService")
local ServerStorage = game:GetService("ServerStorage")
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()

end

function mob.Spawn(name, quantity, map)
	local mobExists = ServerStorage.Mobs:FindFirstChild(name)

	if mobExists then
		for i=1, quantity do
			task.wait(0.5)
			local newMob = mobExists:Clone()
			newMob.HumanoidRootPart.CFrame = map.Start.CFrame
			newMob.Parent = map.Mob

			for i, object in ipairs (newMob:GetDescendants()) do 
				object:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(object, "Mob")
end
end    

coroutine.wrap(mob.Move)(newMob, map)
end

else
	warn("Requested mob does not exist:", name)
end
end

return mob

And on my second script it says
Requested module experienced an error while loading
Here is my script

local mob = require(script.Mob)
local map = workspace.Grassland

for wave=1, 5 do
	print("WAVE STARTING:", wave)
	if wave < 5 then
		mob.Spawn("Zombie", 3 * wave, map)
	elseif wave ==5 then
	mob.Spawn("Zombie", 100, map)
	end

	repeat
		task.wait(1)
	until #map.Mob:GetChildren() == 0

	print("WAVE ENDED")
	task.wait(1)
end

It says the issue it at the first line

Should be

if object:IsA("BasePart") then
2 Likes

Yes, @ZombieCrunchUK is absolutely right. You are missing the if condition identifier at line 29 in your first script. This shall also fix the second error automatically.


Still broken and the module doesn’t work you fixed like 2 errors
image

I am not really good at coding since my talent is all in building sorry it ok if you dont wanna help

Open the ModuleScript.

At the top of the Roblox Studio screen you should see some options.

Look for the SCRIPT tab and click on that.

Then find Format Selection and click on that.

Then click on Format Document.

Now scroll down through the ModuleScript until you see the red underlines. Grab the red lines and all of the function that starts above those red lines and paste it here so we can help find the problem.

Make sure when you are posting here that you click on the </> icon above and paste your code where it says to paste it.

Thank you turns out I just forgot the if and do statement within the start and the end so you helped me remember

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.