Hi, I recently remembered the Realm Jumpers game of 2015 that went to the front of the roblox page, I played it a little today and I thought how I could Make a Monster follow a line and if I find an enemy around, attack him, if I do not find An enemy, continue you Way to somewhere.
Game Exemples : Realm Jumpers , Guest Defense , Clone Tycoon and Castle Defenders.
Please if only one explanation is not an entire script ( I want to do it with my own knowledge with scripting ).
Hello. If you have a monster/enemy already created. That's fine. For this answer I will use the Drooling Zombie free model as an example. You can use the following code as well, but update the definitions as needed. First, create a Script in ServerScriptService. Add the enemy model inside ServerStorage. If you have an invisible BasePart you want to use, leave it just where it is. If you have a model for the spawner, make all Parts able to collide, and choose a Part where you want the enemy to spawn. Now start editing the Script. We must first define our variables. In this case that would be the spawn brick, and the enemy. I will use the Drooling Zombie and the spawn brick will be "Spawn".
local enemy = game.ServerStorage["Drooling Zombie"] local spawn = game.Workspace.Spawn
Now that we have our variables, we will start to create our function to spawn the enemy. I will make a while loop to spawn a zombie every 15 seconds.
while true do local c = enemy:Clone() -- Clone the enemy model. c.Parent = game.Workspace -- Parent it to the Workspace. c:MoveTo(spawn.Position) -- Move the enemy to the center of Spawn's position. wait(15) -- Wait 15 seconds. end
That's all there is to it! In simpler words, we copy an enemy model, parent it to the Workspace, and move it. I hope this helps!