#Tower Defense

1 messages · Page 1 of 1 (latest)

trail vapor
#

i've been trying to do a tower defense from a tutorial, in the script i did when the zombie touch the last waypoint he will be removed. but it didnt work, can someone help me=

burnt spindle
trail vapor
burnt spindle
#

does the mob reach the last waypoint?

trail vapor
#

yes

burnt spindle
#

and it stops moving right?

trail vapor
#

yes

burnt spindle
#

do you get any errors?

trail vapor
#

nope

#

here's the video

#

wrong one

midnight wigeon
#

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

trail vapor
#

u sure it wil work?

#

it doesnt work

stuck ivy
#

just

#

hum.Parent:Destroy()

#

@trail vapor ^

trail vapor
#

i will try it

stuck ivy
#

if ur char moves

#

With the humanoid index u have

#

you should just be able to

#

Destroy the parent

trail vapor
#

im trying it

#

it doesent work

versed steppeBOT
#

studio** You are now Level 3! **studio

stuck ivy
#

that's strange

versed steppeBOT
#

studio** You are now Level 7! **studio

stuck ivy
#

@trail vapor try printing the humanoid and humanoid parent

trail vapor
#

it doesnt let me print it

#

it says a table of function and nil

stuck ivy
hazy parrot
#

maybe make the variable name as smth else then try to destroy it?

trail vapor
#

imma try

#

doesent work either

hazy parrot
#

you set the mob in the parameter as smth else right

#

so for example newEnemy

#

and then did newEnemy:Destroy()

hazy parrot
#

this bug is rlly weird

trail vapor
#

wdym?

hazy parrot
#

unless its that

trail vapor
abstract dragon
#

Ur trying to destroy the module

trail vapor
#

how?

abstract dragon
#

You did Mob.destory

trail vapor
#

mb

abstract dragon
#

Capital letter Mob is the table for the module

#

Lower case mob is your actual mob

trail vapor
#

doesnt work either

abstract dragon
#

Put a print statement above your destroy to see if it's even running

trail vapor
#

its not running in the module

abstract dragon
#

So that means the mob never got to the last waypoint

trail vapor
#

but it got to the last point

abstract dragon
#

Does the last waypoint have canCollide as false

trail vapor
#

nope

abstract dragon
#

Anchor it so it doesn't fall through the baseplate and set the collide to false

#

Then try running it again

trail vapor
#

its anchored and i turned off the CanCollide

#

nothing changed

abstract dragon
#

Is ur waypoint in the ground

trail vapor
#

?

abstract dragon
#

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

trail vapor
#

the mob only reaches the first point of the waypoint

#

then it stops moving

#

and the other mobs push eachother

abstract dragon
versed steppeBOT
#

studio** You are now Level 6! **studio

trail vapor
#

ye

versed steppeBOT
#

studio** You are now Level 4! **studio

abstract dragon
#

Yea so in the video you sent

#

Is that little rectangle the last waypoint

trail vapor
#

yes

abstract dragon
#

Did you make it paper thin or is it half in the ground

trail vapor
#

i make it thin like a paper

abstract dragon
#

Apparently saying a unit of measurement will get me timed out

trail vapor
#

i made it a little bigger and 0.9 of trasparency

abstract dragon
#

Move the waypoint up a bit

#

Just like 2 up

trail vapor
#

up>?

#

up?

#

in the Z coordinate?

abstract dragon
#

Yea

trail vapor
#

i did it

abstract dragon
#

What's it look like now

trail vapor
#

nothing

#

they are stuck together

abstract dragon
#

Screen shot the way point

trail vapor
abstract dragon
#

Hmm

#

Are you sure that's the final waypoint? The mobs stopped before the block

trail vapor
#

its the final waypoint

#

its the last one

#

im gonna rec all the other scripts

abstract dragon
#

Can you take a picture of the waypoints folder

trail vapor
abstract dragon
#

In guessing theres 4 but its better to make sure

trail vapor
#

there are 3 waypoints

#

i tried making a fourth waypoint but its the same

#

same bug

abstract dragon
#

woah

#

wait a minute what is that third script you have

hazy parrot
#

wait

abstract dragon
#

lol

hazy parrot
#

i dont think the move function in the module even runs

#

does it

abstract dragon
#

you never called the mob.move

hazy parrot
abstract dragon
#

yea

hazy parrot
#

wrap it in a coroutine

abstract dragon
#

hes making a seperate script foro every mob so it doesnt really matter

hazy parrot
#

coroutine.wrap(Mob.move)(mob, map) or smth

hazy parrot
#

unless its intended that way

trail vapor
#

now i gtg

#

i gotta got to kare

hazy parrot
#

alr

trail vapor
#

i will be back in 2 hourse

hazy parrot
#

just call the Mob.move when u have time

#

gotcha

trail vapor
#

love ya guys for helping me

hazy parrot
#

take care ofc

abstract dragon
#

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

hazy parrot
#

i mean i would just call it in the mob.spawn that way u dont gotta put that script in every enemy

abstract dragon
abstract dragon
#

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

trail vapor
#

IM BACK

#

@abstract dragon could u explain to me what do i need to do to fix the bug?

#

if u know the solution

abstract dragon
trail vapor
#

why?

abstract dragon
#

its unessecary and the reason why everything is not working lol

trail vapor
#

ok

abstract dragon
#

in the mob modular script

#

could you take a picture of it so its easier to explain

trail vapor
#

picture of what?

abstract dragon
#

nvm i found the old one you posted

#

on this line

trail vapor
#

k

abstract dragon
#

put in
Mob.Move(newmob,workspace.map)

#

oh woops

#

task.spawn(Mob.Move,newmob,workspace.map)

#

put that instead

trail vapor
#

after warn i shoul put that?

abstract dragon
#

before the else

trail vapor
#

k

#

didi

#

did it

#

but newmob is red

abstract dragon
#

take a picture of what u did so i can check

#

newMob

trail vapor
abstract dragon
#

newMob instead of newmob

#

since thats what your variable is called

#

the clone of the mob*

trail vapor
abstract dragon
#

worspace.Waypoints

#

instead of worspace.map

trail vapor
#

ServerScriptService.Main.Mob:25: attempt to concatenate table with string

#

it says this

#

with workspace.waypoints

abstract dragon
#

oh bruh

#

so

#

do you plan on making another map

hazy parrot
#

coroutine.wrap(Mob.Move)(mob,map)

#

try that

trail vapor
#

k

hazy parrot
#

for the arguments put the mob variable and then whatever ur map is idk

trail vapor
#

BURH

#

I DELETED THE MODULE SCRIPT

abstract dragon
#

woops

abstract dragon
trail vapor
#

thanks

abstract dragon
#

but i gave the parameter the waypoints already

hazy parrot
#

ohh

#

wait huh

#

does it not start in the workspace

abstract dragon
#

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

trail vapor
#

k

abstract dragon
#

but as i have done that exact same tutorial before

hazy parrot
versed steppeBOT
#

studio** You are now Level 3! **studio

abstract dragon
#

i got distracted and forgot whwat i was going to say

trail vapor
#

ServerScriptService.Main.Mob:25: attempt to concatenate table with string

this is what it shows me

abstract dragon
#

bruh

abstract dragon
#

what is your file explorer

#

thats not what its called

trail vapor
versed steppeBOT
#

studio** You are now Level 5! **studio

#

studio** You are now Level 5! **studio

abstract dragon
#

the thing on the right side of your screen that shows all the parts

#

i dont know how your path looks like rn

trail vapor
hazy parrot
# trail vapor

try commenting out or removing that line and see if it works

abstract dragon
#

ok i saw it in the video

#

workspace.grassland is the map

trail vapor
#

OMG

#

IT WORKS

#

I PUT THE WARN IN ELSE

#

AND NOW THEY DESTROY

#

WHEN THEY TOUCH THE LAST WAYPOINT

#

THANKS YALL

hazy parrot
#

took WAY longer than it needed to but congrats

abstract dragon
#

replace workspace with map since you passed in that

trail vapor
#

thanks yall for helping me

abstract dragon
#

for future purposes

hazy parrot
#

yea

trail vapor
#

with map it doesnt work

hazy parrot