Need help in making enemy system for my td game

This should work:

function enemy.WalkToWayPoint(thing, timeEachCooldown, position)
	if thing.State == "Dead" then return end
	if thing.CurrentWaypoint + 1 > #map.Waypoints:GetChildren() then return end

	local nextWaypoint = map.Waypoints[thing.CurrentWaypoint + 1]

	thing.CFrame *= CFrame.new(0, 0, -(thing.Speed / timeEachCooldown)
	if (thing.CFrame.Position - nextWaypoint.Position).Magnitude < 1 then
		thing.CurrentWaypoint += 1
	end
end

Also consider removing entities from mobss that are dead/reached end to save resources

Tysm, I will BRB I gtg since at somewhere else out

Ok 1 more problem:

local ts = game:GetService("TweenService")

local EntityMap = {}

game.ReplicatedStorage.Events.Render.OnClientEvent:Connect(function(enemy)
	if enemy and not EntityMap[enemy.ID] then
		EntityMap[enemy.ID] = enemy
		local enemyInstance = enemy.Instance
		enemyInstance = enemyInstance:Clone()
		enemyInstance.Parent = workspace.Enemies
		enemyInstance.HumanoidRootPart.CFrame = workspace["Crash Test Zone"].Waypoints[1].CFrame
		
		for i,v in pairs(enemyInstance:GetChildren())do
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				v.CollisionGroup = "Enemy"
			end
		end
		
		enemy.Instance = enemyInstance
	end
end)

game.ReplicatedStorage.Events.Render.OnClientEvent:Connect(function(enemy, TimeToReach)
	if EntityMap[enemy.ID] then
		print("yes")
		local enemyInstance = EntityMap[enemy.ID].Instance
		local waypoint = EntityMap[enemy.ID].CurrentWaypoint
		waypoint += 1
		
		local goal = {}
		goal.Position = Vector3.new(workspace["Crash Test Zone"].Waypoints[waypoint].Position.X,enemyInstance.HumanoidRootPart.Position.Y, workspace["Crash Test Zone"].Waypoints[waypoint].Position.Z) 
		
		local moving = ts:Create(enemyInstance.HumanoidRootPart, TweenInfo.new(TimeToReach/10), goal)
		moving:Play()
	end
end)

In this video the guy is sliding like that, any fix? nvm i cant upload it for some reason but he keeps sliding on until the end of the map also his speed is fast when his walkspeed is 4

Also after the first tween he doesn’t seem to move at all

Server side is looping through the table of info and sending an event to all the elements

Also I put print on the render event and it does print so no need to worry if it not working

It seems you are extremely new to scripting and I urge you to watch tutorials. I understand they may be hard for people like you to comprehend but at least attempt understanding how concepts like print() work.How To Script On Roblox - Episode 1 (Properties) - YouTube

Hope that was a joke cuz I made my own tower system and unique tower abilities

Yes I am sure that must have been… difficult?

OK tysm I made a working system, I had to ‘borrow’ some math stuff like quadratic bezier to turn the enemy, and some cframe

In my bad pc I can run 100 enemy’s with slight lag

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