#Tower Defense
1 messages · Page 1 of 1 (latest)
ur useing :Destroy on the humanoid not the zombie
even if i do mob:Destroy() it doesnt work
does the mob reach the last waypoint?
yes
and it stops moving right?
yes
do you get any errors?
the thing is you were only destroying the Humanoid and not the whole model... so to fix this, call zombieModel:Destroy() to remove the entire zombie.
and it will work
local ServerStorage = game:GetService("ServerStorage")
local M = {}
function M.Move(zombieModel, map)
local humanoid = zombieModel:WaitForChild("Humanoid")
local root = zombieModel:WaitForChild("HumanoidRootPart")
local waypoints = map.Waypoints:GetChildren()
table.sort(waypoints, function(a, b)
return tonumber(a.Name) < tonumber(b.Name)
end)
humanoid.WalkSpeed = 50
for _, wp in ipairs(waypoints) do
humanoid:MoveTo(wp.Position)
humanoid.MoveToFinished:Wait()
task.wait(2)
end
zombieModel:Destroy()
end
function M.Spawn(name, map)
local template = ServerStorage:FindFirstChild("MobSpawner")
:FindFirstChild(name)
if not template then
warn(name, "does not exist in ServerStorage.MobSpawner")
return
end
local newZombie = template:Clone()
newZombie.Parent = workspace
newZombie:SetPrimaryPartCFrame(map.StartPoint.CFrame)
task.spawn(function()
M.Move(newZombie, map)
end)
return newZombie
end
return M
@trail vapor
@trail vapor
i will try it
if ur char moves
With the humanoid index u have
you should just be able to
Destroy the parent
** You are now Level 3! **
that's strange
** You are now Level 7! **
@trail vapor try printing the humanoid and humanoid parent
thats strange
you have the module name and the variable for the enemy as both mob
maybe make the variable name as smth else then try to destroy it?
you set the mob in the parameter as smth else right
so for example newEnemy
and then did newEnemy:Destroy()
wdym?
Ur trying to destroy the module
how?
You did Mob.destory
mb
Capital letter Mob is the table for the module
Lower case mob is your actual mob
doesnt work either
Put a print statement above your destroy to see if it's even running
its not running in the module
So that means the mob never got to the last waypoint
but it got to the last point
Does the last waypoint have canCollide as false
nope
Anchor it so it doesn't fall through the baseplate and set the collide to false
Then try running it again
Is ur waypoint in the ground
?
Because the mob needs to reach the center of the waypoint to be considered "done"
So if you shove the waypoint in the ground
They can't reach it
the mob only reaches the first point of the waypoint
then it stops moving
and the other mobs push eachother
You mean the last waypoint?
** You are now Level 6! **
ye
** You are now Level 4! **
yes
Did you make it paper thin or is it half in the ground
i make it thin like a paper
Apparently saying a unit of measurement will get me timed out
i made it a little bigger and 0.9 of trasparency
Yea
i did it
What's it look like now
Screen shot the way point
Can you take a picture of the waypoints folder
In guessing theres 4 but its better to make sure
wait
lol
you never called the mob.move
theres nothing calling it
yea
wrap it in a coroutine
hes making a seperate script foro every mob so it doesnt really matter
coroutine.wrap(Mob.move)(mob, map) or smth
i mean you could but that might be inefficient
unless its intended that way
alr
i will be back in 2 hourse
love ya guys for helping me
take care ofc
easiest fix rn would be to change the script in drooling zombie to be
local mobScript = require(path to mob module)
local mob = script.parent
local map = workspace.map
mobscript.move(mob,map)
the better way to fix it is call it in the mob.Spawn part
yeah
i mean i would just call it in the mob.spawn that way u dont gotta put that script in every enemy
in mob.Spawn before the line with the else, you can do this
and then you wouldnt need the script for every zombie
task.spawn(mob.Move,mob,map) would do the same too
something to do with being more up to date
IM BACK
@abstract dragon could u explain to me what do i need to do to fix the bug?
if u know the solution
delete the script that is in the drooling zombie model
why?
its unessecary and the reason why everything is not working lol
ok
in the mob modular script
could you take a picture of it so its easier to explain
picture of what?
k
put in
Mob.Move(newmob,workspace.map)
oh woops
task.spawn(Mob.Move,newmob,workspace.map)
put that instead
after warn i shoul put that?
before the else
newMob instead of newmob
since thats what your variable is called
the clone of the mob*
ServerScriptService.Main.Mob:25: attempt to concatenate table with string
it says this
with workspace.waypoints
k
for the arguments put the mob variable and then whatever ur map is idk
ctrl z
thanks
his problem rn is that mob.move is looking for waypoints in the map parameter
but i gave the parameter the waypoints already
mimimimii
ok whatever
@trail vapor just put in workspace instead of workspace.waypoints
you will need to change that in the future if you want to make more than 1 map
k
but as i have done that exact same tutorial before
uppercase M btw in newmob
** You are now Level 3! **
i got distracted and forgot whwat i was going to say
ServerScriptService.Main.Mob:25: attempt to concatenate table with string
this is what it shows me
bruh
show us line 25
the thing on the right side of your screen that shows all the parts
i dont know how your path looks like rn
try commenting out or removing that line and see if it works
OMG
IT WORKS
I PUT THE WARN IN ELSE
AND NOW THEY DESTROY
WHEN THEY TOUCH THE LAST WAYPOINT
THANKS YALL
took WAY longer than it needed to but congrats
ik
replace workspace with map since you passed in that
thanks yall for helping me
yea
with map it doesnt work
bc i assume ur waypoints are directly under workspace