How to Delay Spawn times at Chrythm's RPG Kit?

Somehow whenever i add Spawn Delay for mobs over 1 seconds game either breaks AI or after killing all enemies it spawn more than the limit of area
Example:
MaximumEnemies in area is 10
but when added Delay it goes over 10 and even 17??

Also made a chance to spawn thingy for mobs but it doesn’t spawn even 10?
it spawns 2~7 somehow and stops till all enemies in area die.

Also seperated AI to work after their spawn no matter how long its, and it works but instead till all of them spawns the script laggs itself.

1 Like

Could you explain what ‘Chrythm’s RPG Kit’ is?

2 Likes

Here:

it a RPG kit but feels better than evercyan and droplet ones.
but needs to be improved even further

Looking back, WOW I wrote some messy code!!! I need to make a new one for sure.
Anyway, I think the reasoning this is happening is because adding a delay will pause the whole system.

Instead, try this:
On line 119 of RPGSystem, there is this line of code:

SpawnEnemy(spawnRegion)

To add a delay, change it to this:

task.delay(1, SpawnEnemy, spawnRegion)

Feel free to change the delay time. I set it to one second as an example.

1 Like

yes it works but… in a different way i can say :d

i wanted it to work like “spawn enemies by their own timer” something like that
this one just delays the task but still spawns them all at the same time

In that case, try task.spawn instead and remove the number for the delay time.

task.spawn(SpawnEnemy, spawnRegion)

Then inside the spawn function, you can use task.wait(seconds) with the amount of time being read from the enemy somewhere. Something like task.wait(enemy.SpawnTime)

1 Like

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