Tower Placement - Tower Defense Tutorial #6

Поділитися
Вставка
  • Опубліковано 3 тра 2024
  • Building off the back of our raycasting video, we can finish the tower placement system. This one is a biggie!
    DISCORD ► / discord
    TWITTER ►@gnomecodeRBLX
    TIMESTAMPS►
    0:00 Intro
    0:35 Creating GUI
    3:34 Creating Placeholder Tower
    7:45 Positioning Towers
    11:55 Raycast Params
    15:25 Fixing height offset
    17:55 Fixing Collisions
    20:17 Placing Towers
    29:33 Removing Placeholders
    31:29 Resricting Placement
    36:50 Tower Rotation
    39:30 Outro

КОМЕНТАРІ • 2,8 тис.

  • @GnomeCode
    @GnomeCode  2 роки тому +234

    Merry Christmas Gnomes! Hope you're all well. There will be a short break in the episodes during the holiday but we'll be back to work soon!

    • @PineBloxx
      @PineBloxx 2 роки тому +8

      Merry Christmas Gnome! You deserve a break! Congratulations for a great year and have a great holiday!!

    • @that1gamerlad98
      @that1gamerlad98 2 роки тому +4

      Merry Christmas Gnome! Have a nice time and enjoy!

    • @Theroijr
      @Theroijr 2 роки тому +7

      That’s ok because it’s Christmas I was wondering if you can help me and my friend with a game we’re working on

    • @candykid44
      @candykid44 2 роки тому +10

      merry chrysler

    • @tricky6614
      @tricky6614 2 роки тому +3

      marry christmas ❤😍😘🥰

  • @shahanawahid8797
    @shahanawahid8797 2 роки тому +4

    Absolutely brilliant tutorial. Youre very easy to understand what everything is and why we need it. Thank you.

  • @0_Shadow_1
    @0_Shadow_1 7 місяців тому +75

    For anyone making Towers R6 make it like this
    local x = result.Position.X
    local y = result.Position.Y + TowerToSpawn["Left Leg"].Size.Y + (TowerToSpawn.PrimaryPart.Size.Y/2)
    local z = result.Position.Z
    And set HipHeight to 0 if your tower floats in the air (for small towers)

  • @winchesterplayz9179
    @winchesterplayz9179 Рік тому

    Your video was very helpful, I'm still learning and getting the hang of it still. I'm into House and EDM. I look forward to seeing more of your

  • @Meex21
    @Meex21 Рік тому +1

    This tutorial helped me a lot with my tower defense game! thanks gnomecode!

  • @baconsplayz8079
    @baconsplayz8079 2 роки тому +9

    Thanks for teaching us and this improved my building skills, Thank you for the help and stuff.

  • @user-Aceproductions
    @user-Aceproductions 10 місяців тому +173

    For anyone who’s code says depreciated it is because blacklist was removed from the game. Replace the word blacklist with exclude and it will work

    • @slobberyflame19
      @slobberyflame19 10 місяців тому +2

      Mine still don’t work

    • @slobberyflame19
      @slobberyflame19 10 місяців тому +1

      Nvm it work now

    • @catgaming512
      @catgaming512 9 місяців тому +2

      thanks for the help, i wondered why it didnt work

    • @yicewie
      @yicewie 9 місяців тому

      @@slobberyflame19 what did you do?

    • @ObliviousNoob1
      @ObliviousNoob1 9 місяців тому

      Yo bro your A w

  • @christianhelle
    @christianhelle 2 роки тому +78

    These videos are really great. I'm building a similar game together with my 10 year old son and your way of explaining is so much better and beginner friendly than my way. I'm a developer myself and have been for the last 20 years, but I have close to zero teaching experience. This has been very helpful for my son which tries to watch these on his own. Thanks a ton for publishing these

  • @RichRBLX
    @RichRBLX 2 роки тому +5

    your tutorials are great gnome, im on holiday but when i get back i'll continue on this series since ive only done the first 2 episodes :/

  • @zyreth0
    @zyreth0 2 роки тому +4

    This is a very good tutorial! I learned many new things :D

  • @The_Noooob
    @The_Noooob 5 місяців тому

    Thank you GnomeCode! Your tutorials are the best!

  • @Tealenn
    @Tealenn 3 місяці тому +2

    This was a big one, thank you gnome for a good tutorial!

  • @Splffo
    @Splffo 2 роки тому +19

    Nice tutorial man! it sure took me a long time to fix the mistakes i wrote inside the script.
    But the game is turning into a real tower defense game!

    • @Front1ine
      @Front1ine 6 місяців тому +1

      bro the update ruined the developing for my game

    • @Fabi-ch8sz
      @Fabi-ch8sz 5 місяців тому

      ​@@Front1ineDo u can place multiple Towers?

  • @EnderVampire
    @EnderVampire 2 роки тому +7

    Hey Gnome! Definitely continue this series because it definitely is amazing, and you do a really good job on explaining the more complex things in coding, but I've been looking everywhere for a tutorial or even something to help me make a game like Phasmophobia or even a really good already made Roblox version called "Specter," so if you can help me make a game like this, I would greatly appreciate it. Keep making amazing vids!

  • @z_n.
    @z_n. 7 місяців тому +37

    Guys, "Blacklist" is now deprecated. So, instead of "Blacklist", it's "Exclude" im pretty sure. Just read it from a devforum.

    • @Toto70Dev
      @Toto70Dev 6 місяців тому +2

      Yeah its good

    • @spriteman1925
      @spriteman1925 6 місяців тому +2

      If something is deprecated itll show it and then if you hover on it itll tell you what to do to make it up to date

    • @FrozenWater-real
      @FrozenWater-real 5 місяців тому +1

      I still did blacklist and it worked but it didn’t show anything in the update too, so I’ll still use blacklist.

    • @spriteman1925
      @spriteman1925 5 місяців тому +2

      @FrozenWater-ce8jn if you dont use exclude your game is going to break within a year

    • @spriteman1925
      @spriteman1925 5 місяців тому +2

      ​@@FrozenWater-realor later idek just dont use it

  • @akiprox7
    @akiprox7 Рік тому

    Best series in the world, ty!

  • @livestats766
    @livestats766 2 роки тому +3

    Hi gnomecode! this tutorial was amazing! Happy holidays and stay safe!

  • @foxydev5551
    @foxydev5551 2 роки тому +7

    Thank you!!! I’ve been looking for a good tutorial for a while now. One thing that you should do soon, is tower animations and a lobby with teleports to the maps for multiplayer..? Maybe a shop with currency too. Just suggestions!

    • @kingmatt7545
      @kingmatt7545 2 роки тому

      he will do it just for later episodes

  • @fysaccc6636
    @fysaccc6636 Рік тому

    Amazing tutorial! i love it!!

  • @yasboy8268
    @yasboy8268 13 днів тому

    This rly helped me i was stuck for 1 hour but it's now ok Thanks man!

  • @NOYOUCANTTAKEALLTHEPINEAPPL3S
    @NOYOUCANTTAKEALLTHEPINEAPPL3S 2 роки тому +7

    This is so good! Keep up the tower defense tutorials gnomecode!

  • @HurelyDev
    @HurelyDev 2 роки тому +46

    back again for another tip! heres how to make a tower that spawns units: 1: make a units folder in replicatedstorage, make a unit. 2: make a script in its humanoid and put this in it:
    local map = workspace.Daycare -- replace daycare with your map
    -- do it for how much waypoints you have
    script.Parent:MoveTo(map.Waypoints["9"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["8"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["7"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["6"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["5"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["4"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["3"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["2"].Position)
    script.Parent.MoveToFinished:Wait()
    script.Parent:MoveTo(map.Waypoints["1"].Position)
    script.Parent.MoveToFinished:Wait()
    next, if there is a script in its humanoidrootpart, replace it with this: script.Parent.Touched:Connect(function(hit)
    local plr = game.Players.LocalPlayer
    if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= "Mini-Purple" then -- replace Mini-Purple with your units name
    hit.Parent.Humanoid.Health -= 2
    script.Parent.Parent:Destroy()
    end
    end)
    Next, put this script in the tower that will spawn the units:
    local tower = script.Parent.Parent
    local mobs = workspace.Mobs
    local function FindNearestTarget()
    local maxDistance = 50
    local nearestTarget = nil
    for i, target in ipairs(mobs:GetChildren()) do
    local distance = (target.HumanoidRootPart.Position - tower.HumanoidRootPart.Position).Magnitude
    if distance < maxDistance then
    nearestTarget = target
    maxDistance = distance
    end
    end

    return nearestTarget
    end
    local function SpawnUnit()
    local unit = game.ReplicatedStorage.Units["Mini-Purple"]:Clone() -- replace Mini-Purple with your units name
    unit.Parent = workspace.Towers
    unit.HumanoidRootPart.CFrame = workspace.Daycare.Waypoints["9"].CFrame -- replace it with the last waypoint on your map
    end
    while true do
    task.wait(2)
    local target = FindNearestTarget()
    if target then
    target.Humanoid.Health -= 3
    end
    wait(1)
    SpawnUnit()
    end
    Now your done!

    • @ownerthegamer1218
      @ownerthegamer1218 2 роки тому +1

      Thank you

    • @ownerthegamer1218
      @ownerthegamer1218 2 роки тому

      Sorry but it says "HumanoidRootPart is not part of workspace" how do I fix that?

    • @ownerthegamer1218
      @ownerthegamer1218 2 роки тому

      Can you tell me how to do all of this? I might have messed something up

    • @HurelyDev
      @HurelyDev 2 роки тому

      @@ownerthegamer1218 do you have discord

    • @ownerthegamer1218
      @ownerthegamer1218 2 роки тому

      @@HurelyDev yes Owner_Pro1#0988

  • @loupezz1716
    @loupezz1716 Рік тому

    thank you so so so much, i really needed this for my game

  • @angomango173
    @angomango173 3 місяці тому +1

    Honestly this series is made so well it deserves a subscribe. Lets get this guy to 100K!

    • @yukys1
      @yukys1 2 місяці тому

      For real man I just made my own td called zombie tower defense

    • @angomango173
      @angomango173 2 місяці тому

      @@yukys1 ok

    • @angomango173
      @angomango173 2 місяці тому

      @@yukys1 no advertisements

    • @yukys1
      @yukys1 2 місяці тому

      Nice

  • @noobgaming0216
    @noobgaming0216 2 роки тому +14

    Nice tutorial video, try doing a tower that spawns an ally (ex, military base spawns humvee)

  • @stoneh8733
    @stoneh8733 2 місяці тому

    for those of you having the same issue i was having, if your character is still in the ground when you spawn it in, spawn a part at the bottom of the legs, so its colliding with the legs, move the legs to where the torso should be and move the torso, arms, and head up so it looks like it should normally, then get rid of the part. thats what i did and it works.

  • @Hudson-ft8go
    @Hudson-ft8go 19 днів тому

    Thank you so much me and my friends were making a tower defense game and we gave up before we made waves but now were doing where i code and he models stuff

  • @hypergamer5392
    @hypergamer5392 2 роки тому +7

    Thank you for the video! I added some extra things to the script like when you press x it withdraws the tower and I also added a custom health bar can't wait for more videos!

    • @GnomeCode
      @GnomeCode  2 роки тому +6

      Nice work!

    • @alexanderholmgaardlindholt4922
      @alexanderholmgaardlindholt4922 2 роки тому

      VERY simple, but nice work yea.

    • @Scorpio894
      @Scorpio894 2 роки тому

      How do I do that I would really love to where do I add it in

    • @Scorpio894
      @Scorpio894 2 роки тому +1

      @@alexanderholmgaardlindholt4922 do you know how to do that I would like to

    • @oskargd1220
      @oskargd1220 2 роки тому +1

      @@Scorpio894 Just learn scripting. Search up pea factory, how are you gonna add more to the game once he finishes the tutorial? Your game will just die.

  • @rgby1367
    @rgby1367 2 роки тому +3

    Pretty impressive tutorial. I personally would have done few things slightly different, but it was interesting to see what you did. I have tried making a few tower defense games before, but I'm never too sure how I should make the towers attack the enemy that is closest to the end.

    • @ThestickmanEmperor
      @ThestickmanEmperor 7 місяців тому

      Maybe try having attack teh unit that has existed the longest?

    • @Mini-se6cx
      @Mini-se6cx 7 місяців тому

      @@ThestickmanEmperorslower enemies completely invalidates this

    • @rcen3493
      @rcen3493 7 місяців тому

      @@ThestickmanEmperor Problem with that is, is slow enemies spawn and fast enemies spawn too, the fast enemies wont be targeted.

  • @mrnoobyt3328
    @mrnoobyt3328 9 місяців тому

    This vid actually took me two days to finish💀 nice tutorial!

  • @customizednasheeds6536
    @customizednasheeds6536 Рік тому

    Good job, dude

  • @Lexii.lindsay3569
    @Lexii.lindsay3569 7 місяців тому +11

    This playlist is literally the equivalent to classes people pay to get about game development and such, this is straight up a blessing

    • @dandinzin
      @dandinzin 7 місяців тому

      Yes, the series is really great just finished it
      And I see your comment is recent, if you are just starting out, good luck and have fun!

    • @meg-michelle
      @meg-michelle 7 місяців тому

      do you know if the tower placing works for mobile users too?

    • @dandinzin
      @dandinzin 7 місяців тому

      It does, later in the series gnome code goes into mobile support, but the ray cast works@@meg-michelle

    • @Fonzi2
      @Fonzi2 7 місяців тому

      @@dandinzin Hey can you help me, whenever I go to place a unit it shows its on the ground but then it spawns in the air about 1 to 2 studs up, pls help

    • @ThatoneguyTDS
      @ThatoneguyTDS 6 місяців тому

      "straight up blessing"💀💀💀💀💀

  • @bloxingz168
    @bloxingz168 11 місяців тому +13

    if you want to fix off hight of the tower just change hiphight of humanoid to -0.5 and in script change it too 1 for small towers like tds
    😃

  • @arnex8560
    @arnex8560 Рік тому

    you did a good job, i learn so mutch from you thanks!!!

  • @thedumbaviator5536
    @thedumbaviator5536 Рік тому

    40 minutes of fun

  • @tinpothead6586
    @tinpothead6586 2 роки тому +31

    This is very good! I have some suggestions for future episodes: Modes, Animations, Tower Settings (set tower to first, strongest, closest, etc. ), Appearance changes in upgrades Edit: Maybe even make a shop of towers if you can

    • @RedLogged
      @RedLogged 2 роки тому +1

      it isnt like he was most likely was gonna do this due to the fact that basically every tower defense game has this, not really and original idea but its normal in a tower defense game

    • @alexanderholmgaardlindholt4922
      @alexanderholmgaardlindholt4922 2 роки тому +2

      @@RedLogged the first tower defense game on Roblox does not have Tower Settings
      Edit: Many others don't too, even the first Tower Defense Game made. (out of roblox)

    • @Nachoegg
      @Nachoegg 2 роки тому

      He already did a video about Animations its the part 3

    • @tinpothead6586
      @tinpothead6586 2 роки тому

      @@Nachoegg tower animations

    • @Nachoegg
      @Nachoegg 2 роки тому

      @@tinpothead6586 oh ok well he only did mob animations in part 3 but good idea

  • @alexanderholmgaardlindholt4922
    @alexanderholmgaardlindholt4922 2 роки тому +4

    I like the tutorial, i don't follow it but it looks very good, and not too hard for beginners :)
    Good work GnomeCode!

    • @GnomeCode
      @GnomeCode  2 роки тому +3

      That's great to hear, thank you!

    • @-Cloud-9-Nine-
      @-Cloud-9-Nine- 9 місяців тому

      As a beginner myself, this tutorial is so helpful and educational!

  • @TheRealEliteZ0
    @TheRealEliteZ0 11 місяців тому

    i like these tutorials

  • @airpet3870
    @airpet3870 Рік тому

    TNice tutorials was excellent man, thank you so much! I'm a 40yr old noob that's always wanted to try making soft and never got around to it. I'm

  • @TheREALceren
    @TheREALceren 2 роки тому +28

    Tip: If you want a grid, use local x = math.floor(result.Position.X)
    local y = math.floor(result.Position.Y + towerToSpawn.Humanoid.HipHeight + (towerToSpawn.PrimaryPart.Size.Y / 2))
    local z = math.floor(result.Position.Z)

    • @Emil_Jansson
      @Emil_Jansson 2 роки тому

      math.round is more correct in this case and no need to do it on the y-axis.

    • @TheREALceren
      @TheREALceren 2 роки тому

      @@Emil_Jansson yeah i dont know that math.round existed im sorry

    • @qwerty_qwerty
      @qwerty_qwerty Рік тому

      this broke my script 😃

    • @ALocalMaid
      @ALocalMaid Рік тому +2

      @@qwerty_qwerty Don't trust random code that doesn't tell you what to do with it

    • @kekefufu2748
      @kekefufu2748 Рік тому

      Yo this works so well thanks man

  • @cybecc
    @cybecc 2 роки тому +13

    at the line 52, here is the actual line:
    local y = result.Position.Y + towerToSpawn.Humanoid.HipHeight + (towerToSpawn.PrimaryPart.Size.Y * 1.5)

    • @yazanzy
      @yazanzy 2 роки тому

      THANKS SOOOOO MUSH

    • @gpro1773
      @gpro1773 10 місяців тому

      It goes a lil bit higher than normal, but it helped me fix a bug. Thanks!

    • @baguettelord9741
      @baguettelord9741 5 місяців тому

      Yes, and make sure that hipheight is 0 and not 2

    • @jamesgamertime435
      @jamesgamertime435 4 місяці тому

      Thank you

  • @Benji-mk6pg
    @Benji-mk6pg 2 роки тому +1

    18:05 leaving it here btw great series

  • @Fat_GaIa
    @Fat_GaIa 2 роки тому +1

    17:07 you can also just add 2 lol
    but, thank you so much for the help I've been wanting to do this for a while and you let it happen, thank you!

    • @felixiplang
      @felixiplang 28 днів тому

      Because he used those calculations, he can now use rigs of different sizes and heights and it will still work. It wouldn't work if he added 2, however.

  • @hudaiscool
    @hudaiscool 2 роки тому +4

    this help me alot! also I have a suggestion: a skin shop for towers, require money to spawn tower, a map teleporter [in lobby and then you select map in elevator/map select then teleported], gamemodes, gives buff tower.

    • @mouseinglasses
      @mouseinglasses 2 роки тому

      Tds player?

    • @sukiyaki4623
      @sukiyaki4623 2 роки тому

      @@mouseinglasses nope literally just the basics of a roblox td game

    • @Bot-iv7io
      @Bot-iv7io 9 місяців тому

      @@mouseinglasses tds doesnt let you select maps unless its in survival so it leans more towards critical tower defense

  • @KoolKiwi_
    @KoolKiwi_ 9 місяців тому +8

    I recently encountered a problem where my gun wouldn't stick to my tower. I later figured out that I had to un-anchor it and I also made it a union to keep it more neat. I hope this helps you all!

    • @BhroaaFN
      @BhroaaFN 8 місяців тому +1

      The comment i needed to hear

    • @cosmix2711
      @cosmix2711 8 місяців тому

      I did that but for some reason now it just falls off
      Edit: btw I have r6 model

    • @cosmix2711
      @cosmix2711 8 місяців тому

      Like it just falls to the ground instead of sticking to it

    • @KoolKiwi_
      @KoolKiwi_ 8 місяців тому

      is it un-anchored and everything?@@cosmix2711

    • @Comptoon
      @Comptoon 8 місяців тому

      @@cosmix2711 (if you use the dfeault roblox animator) make the animation without the gun (i suggest duplicating it in case something rong happens) then after you finished the animation, rig the model with the weapon (because more motor parts causes error on roblox animator). [idk if i am right but..]

  • @Gabriel-kk8ct
    @Gabriel-kk8ct Рік тому

    Absolutely!!

  • @cijohnbaby6885
    @cijohnbaby6885 Рік тому

    That's so cool!

  • @YeorgeX
    @YeorgeX 9 місяців тому +11

    If you are having problems with the hipheight on your r6 character then go to the render stepped function and at the y position where it says local y = result.Position.Y + tower to spawn.Humanoid.Hipheight then in front of it add + 1 + (towerToSpawn.PrimaryPart.Size.Y /2) and set the hipheight for the humanoid to 0 in your character.

    • @anxerx4186
      @anxerx4186 9 місяців тому

      thx it fixed my hipheight bug!

    • @YeorgeX
      @YeorgeX 9 місяців тому

      @@anxerx4186 np.

    • @cobaltzero
      @cobaltzero 4 місяці тому

      for me * 2 worked as well

    • @YeorgeX
      @YeorgeX 4 місяці тому

      @@cobaltzero Ye, bc u used r15

    • @NeoQQ
      @NeoQQ 2 місяці тому

      Hey bro for me ita still in the ground to place how do i fix it

  • @magmaxton
    @magmaxton 2 роки тому +3

    Amazing work! I have a question, will you make tower animations?

    • @livestats766
      @livestats766 2 роки тому

      I think yes. Because he needs to work the towers more.

    • @GnomeCode
      @GnomeCode  2 роки тому +3

      Yep, will be in episode 7

    • @thuytrangoan2508
      @thuytrangoan2508 2 роки тому

      Pog

    • @livestats766
      @livestats766 2 роки тому

      @@mijott it will be delayed maybe 1 day or 2,he sayed it in the comments

  • @typicalaverage
    @typicalaverage 2 роки тому +92

    So for those who want to make hidden enemies *actually* work, this is how
    First, you add a configuration folder into *every* single zombie you made, and rename it to "Attributes" or whatever you want.
    Next, add a BoolValue and rename it to "Hidden".
    After that, go to your tower and in the "if target then" script, add
    if target.Attributes.Hidden.Value == false then
    target.Humanoid:TakeDamage(1)
    end
    And for those whom want to make their towers an ACTUAL npc and make them work, here's the script i used (thanks to another guy for letting me know how to make towers face the enemy (PUT THE SCRIPT IN HUMANOIDROOTPART)
    local tower = script.Parent.Parent
    local mobs = workspace.Mob
    local part = script.Parent
    local function FindNearestTarget()
    local maxDistance = 25
    local nearestTarget = nil
    for i, target in ipairs(mobs:GetChildren()) do
    local distance = (target.HumanoidRootPart.Position - tower.HumanoidRootPart.Position).Magnitude
    if distance < maxDistance then
    nearestTarget = target
    maxDistance = distance
    end
    end
    return nearestTarget
    end
    while true do
    local target = FindNearestTarget()
    if target then
    target.Humanoid:TakeDamage(1)
    else

    end

    task.wait(0.1)
    end
    Hope it worked! :D

    • @chronos3370
      @chronos3370 2 роки тому +1

      thx i didnt used but i think imma use it :D

    • @typicalaverage
      @typicalaverage 2 роки тому +1

      I forgot the humanoid facing part but that's in the next episode, oh well!

    • @DustedMain
      @DustedMain 2 роки тому

      i cant seem to make it so that specific towers CAN see hidden

    • @wither7293
      @wither7293 2 роки тому

      Can you make that its LIKE with the updated tower script

    • @goofymemer_1
      @goofymemer_1 Рік тому

      now I want a tower that can attack hiddens

  • @bozominuselevation
    @bozominuselevation 8 місяців тому +2

    if your character doesn't have a hipheight, click the model and check it's size, and then make the hip height double the size of your model. it should work if you have a normal r6 rig.

  • @kapochannelby7047
    @kapochannelby7047 Рік тому

    thank you homie appreciate it dawg,

  • @andr31d3n9
    @andr31d3n9 2 роки тому +20

    saving my spot! 31:40, the game is going well! i customized the animations, made my own troops, and learned a few things or more about scripting! this tutorial is efficient, and great to follow for starters! loved it!

    • @overlord2754
      @overlord2754 2 роки тому

      I think i should give up

    • @kiefsOnlinegames
      @kiefsOnlinegames 2 роки тому

      How did you not get error i got an error at 29:30

    • @eee6502
      @eee6502 2 роки тому

      @@kiefsOnlinegames what was ur error?

    • @kiefsOnlinegames
      @kiefsOnlinegames 2 роки тому

      @@eee6502 my tower isnt placing but i found out the problem

    • @kiefsOnlinegames
      @kiefsOnlinegames 2 роки тому

      @kiefsOnlinegames i finally found out.. stupid me

  • @lordwigstyle8017
    @lordwigstyle8017 2 роки тому +8

    He didnt mention this but if you are using a model, not just a part use this in towertesting: local distance = (target.HumanoidRootPart.Position - tower.HumanoidRootPart.Position).Magnitude

    • @FrazdYT
      @FrazdYT 2 роки тому

      at WHAT LINE

    • @roboticgames2989
      @roboticgames2989 9 місяців тому +1

      @@FrazdYT bruh if you see a local that means its a variable and local distance so replaces what local distance is with that

  • @ThatOneNoobDev
    @ThatOneNoobDev 8 місяців тому

    If anyone is having problems like colliding with the tower that you placed switch the rig to r15 and you can go through them

  • @licenciadopii803
    @licenciadopii803 Рік тому

    i was at the 8 minutes mark then i got engrossed in the potential masterpiece i could make and started dancing and bobbinb my head

  • @mrnoobyt3328
    @mrnoobyt3328 9 місяців тому +12

    Collision Fix: If you still collide with your towers (can't walk through them) then, move your tower to workspace and unanchor it and anchor it again and put it back into the towers folder in replicatedstorage

    • @thatonekittykat
      @thatonekittykat 9 місяців тому

      I unanchored everything with an anchor enable/disable, still wont collide.

    • @trafed898
      @trafed898 9 місяців тому

      Ah me too

    • @mrnoobyt3328
      @mrnoobyt3328 9 місяців тому

      @@trafed898 you fixed it?

    • @trafed898
      @trafed898 8 місяців тому

      @@mrnoobyt3328 no

    • @LardonDash
      @LardonDash 8 місяців тому

      Hello guys ! can anyone help me pls ? my troup do not spawn where i click he spawn in its default workspace location ! (and I watched the video 5 times (at least) and I'm still blocked)(And (last time) there's no error so I can't correct it(yeah it's long sorry).)

  • @stefotheguy2766
    @stefotheguy2766 2 роки тому +62

    15:45 Warning flying gnomes have been spotted around the globe you can't run or hide they will find you

  • @Shadowalp
    @Shadowalp Рік тому

    thank you so much

  • @enb6720
    @enb6720 2 роки тому +16

    R6 Models have a default HipHeight of 0, to fix this change it to 2 in the Humanoid settings in your Tower model. :)

    • @SD-uv5bk
      @SD-uv5bk 2 роки тому +2

      THANKS!

    • @sraiaan
      @sraiaan 2 роки тому +1

      there is a flaw to this, and thats that when the tower spawns, it will be floating.
      i cant find a way to fix it

    • @SD-uv5bk
      @SD-uv5bk 2 роки тому +1

      @@sraiaan same this has happened to me, so I just switched the tower to R15… I’m sure there is a way to fix it with R6 but I am not aware of it

    • @yea152
      @yea152 2 роки тому

      @@sraiaan unanchor your primary part, it adjusts itself to the ground and on later levels anchor the humanoidrootpart so it stays still.

    • @ThatOneTechy
      @ThatOneTechy 2 роки тому +4

      @@sraiaan Do this:
      local y = result.Position.Y + towerToSpawn.Humanoid.HipHeight + 1.44 + (towerToSpawn.PrimaryPart.Size.Y / 2)
      this spawns its at the right without making it float. (Replace 1.44 with your characters leg height

  • @wasdwar4egregsgsfdgrsdfgsreg
    @wasdwar4egregsgsfdgrsdfgsreg 8 місяців тому +18

    if you want to make it so you can cancel the tower placement, go right under where you put the rotation part and put
    elseif input.KeyCode == Enum.KeyCode.Q then
    RemovePlaceholderTower()
    end
    you can replace the keycode with anything you want but I just put it as Q

    • @concealedVV
      @concealedVV 8 місяців тому +2

      on what line?

    • @R1S1SKA
      @R1S1SKA 7 місяців тому +1

      Thank you!

    • @captainmojo3771
      @captainmojo3771 4 місяці тому

      for anyone who is having trouble with this do this to make it work right.
      RemovePlaceholderTower()
      end
      ------------------------------------------------------------------------------------------------------------------ don't copt anything before this line this is just to show where to put it
      elseif input.KeyCode == Enum.KeyCode.R then
      rotation += 90
      elseif input.KeyCode == Enum.KeyCode.Q then
      RemovePlaceholderTower()
      end


      end
      end)

  • @user-qq7nn3oy4y
    @user-qq7nn3oy4y 8 місяців тому

    you're god. Thank you Sooooooooooooooooooooooooooooooo much

  • @demonicdrowser
    @demonicdrowser Рік тому

    thnx so much!

  • @chunkyfunkymonkey
    @chunkyfunkymonkey 2 роки тому +3

    if you want the height offsett fixed with r6 use + towerToSpawn.Humanoid.HipHeight + 2 + (towerToSpawn.PrimaryPart.Size.Y / 2) instead of + towerToSpawn.Humanoid.HipHeight + (towerToSpawn.PrimaryPart.Size.Y / 2) make sure ur rigs hip height is 0 if you wish to do this.

    • @eduardobrtx3587
      @eduardobrtx3587 2 роки тому

      BROO thank You so much!!!!!!

    • @terrencelin5133
      @terrencelin5133 Рік тому

      or you could just set the humanoid to have a hipheight of 2

    • @chunkyfunkymonkey
      @chunkyfunkymonkey Рік тому

      @@terrencelin5133 no, this doesnt work for r6.

    • @chunkyfunkymonkey
      @chunkyfunkymonkey Рік тому

      and if u have multiple sized r6 towers, you cant easily change that.

  • @nol12bloxYT
    @nol12bloxYT Рік тому +35

    For anyone who has an R6 model for your tower ("Select the humanoid to check") and when you place the tower it has a floating bug, change the RigType from R6 to R15 in the humanoid.

    • @wuwapit8293
      @wuwapit8293 Рік тому

      When i change the rig it just changes the arms legs and torso to brick what can i do to change that

    • @nol12bloxYT
      @nol12bloxYT Рік тому

      @@wuwapit8293 maybe try using a different model that is R15 or maybe mess around with the hipheight.

    • @wuwapit8293
      @wuwapit8293 Рік тому

      @@nol12bloxYT setting hipheight to 0 works but when im placing the tower it clips into the floor

    • @nol12bloxYT
      @nol12bloxYT Рік тому

      @@wuwapit8293 I had the same problem, but when I changed the rigtype to R15 and set hipheight to 2, it seems to work fine to me.

    • @wuwapit8293
      @wuwapit8293 Рік тому +20

      @@nol12bloxYT found a solution
      add the height of one of the legs:
      local y = result.Position.Y + towerToSpawn:FindFirstChild("Left Leg").Size.Y + (towerToSpawn.PrimaryPart.Size.Y / 2)

  • @alieltouny1264
    @alieltouny1264 2 роки тому +1

    Your the best

  • @camella-andreijosepho.escu9758
    @camella-andreijosepho.escu9758 11 місяців тому +1

    Your videos are great! i just have a teeny tiny problem. When i click add group in collision groups it gives me an error that has to do with built in studio scripts and i cant add any group even when i try to.

  • @literallythatbaconyt5476
    @literallythatbaconyt5476 2 роки тому +5

    i need help: when i place another tower it just goes back to it's position when i put the tower in ReplicatedStorage
    and there is a random block (or torso of my tower) in the left side, so GnomeCode help me with this problem when you see this. And also my tower’s lower body is stuck on floor when your preparing to place my tower. And how to make a tower and how to give your tower a weapon.

    • @thecastorzs7373
      @thecastorzs7373 2 роки тому

      Same and I don't know how to fix either

    • @zgray3807
      @zgray3807 2 роки тому

      Same for the 1st half

  • @harryxd8141
    @harryxd8141 7 місяців тому +3

    the collision with mobs dosent work mobs cant walk past my slinger

  • @Somftix
    @Somftix 21 день тому

    Thanks 😊

  • @UTubeStudios
    @UTubeStudios 8 місяців тому

    thanks it helped so much!

    • @ZionSalcedo
      @ZionSalcedo 8 місяців тому

      Can you post your code in a comment I can't get mine to work

    • @UTubeStudios
      @UTubeStudios 8 місяців тому

      @@ZionSalcedo for what scripts

    • @ZionSalcedo
      @ZionSalcedo 8 місяців тому

      @@UTubeStudios Gamecontroller script

  • @lilianaramirez8496
    @lilianaramirez8496 Рік тому +5

    If anyone is using R6 then replace your Y position script, with local y =result.Position.Y + towerToSpawn.Humanoid.HipHeight + (towerToSpawn.PrimaryPart.Size.Y + 1)

  • @KielRussee
    @KielRussee 2 роки тому +23

    38:43 SMALL DETAIL : For anyone that wants the rotation to "save" for placing the next unit just put rotation = rotiation not rotation = 0

    • @KarZeCompany
      @KarZeCompany 2 роки тому +1

      You don't even need that code if you want the rotation to "save"

    • @testings2890
      @testings2890 2 роки тому

      i need help, how do i make it look at the enemie, it wont damage it. Please respond with code, rthanks

    • @capistudio867
      @capistudio867 2 роки тому

      did i do anything wrong, gnome code?
      local ReplicatedStorage = game:GetService("ReplicatedStorage")
      local RunService = game:GetService("RunService")
      local PhysicsService = game:GetService("PhysicsService")
      local UserInputService = game:GetService("UserInputService")
      local Events = ReplicatedStorage:WaitForChild("Events")
      local Towers = ReplicatedStorage:WaitForChild("Towers")
      local rotation = 0
      local TowerToSpawn = nil
      local CanPlace = false
      local Camera = workspace.CurrentCamera
      local gui = script.Parent
      local function MouseRaycast(blacklist)
      local mousePos = UserInputService:GetMouseLocation()
      local raycastParams = RaycastParams.new()

      raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
      raycastParams.FilterDescendantsInstances = blacklist

      local mouseRay = Camera:ViewportPointToRay(mousePos.X, mousePos.Y)
      local raycastResult = workspace:Raycast(mouseRay.Origin, mouseRay.Direction * 1000, raycastParams)

      return raycastResult
      end
      local function RemovePlaceholderTower()
      if TowerToSpawn then
      TowerToSpawn:Destroy()
      TowerToSpawn = nil
      rotation = rotation
      end
      end
      local function AddPlaceholderTower(name)
      local TowerExists = Towers:FindFirstChild(name)

      if TowerExists then
      TowerToSpawn = TowerExists:Clone()
      TowerToSpawn.Parent = workspace.Towers
      end

      for i, object in ipairs(TowerToSpawn:GetDescendants()) do
      if object:IsA("BasePart") then
      PhysicsService:SetPartCollisionGroup(object, "Tower")
      object.Material = Enum.Material.ForceField
      object.Transparency = 0.301
      object.Color = Color3.fromRGB(85, 255, 0)
      end
      end
      end
      UserInputService.InputBegan:Connect(function(input, processed)
      if processed then
      return
      end

      if TowerToSpawn then
      if CanPlace then
      if input.UserInputType == Enum.UserInputType.MouseButton1 then
      Events.TowerSpawn:FireServer(TowerToSpawn.Name, TowerToSpawn.PrimaryPart.CFrame)
      RemovePlaceholderTower()
      end
      elseif input.KeyCode == Enum.KeyCode.R then
      rotation += 90
      end
      end
      end)
      local function ColorPlaceholderTower(color)
      for i, object in ipairs(TowerToSpawn:GetDescendants()) do
      if object:IsA("BasePart") then
      object.Color = color
      end
      end
      end
      gui.MainFrame.button1.Activated:Connect(function()
      AddPlaceholderTower("Patty")
      end)
      RunService.RenderStepped:Connect(function()
      local result = MouseRaycast({TowerToSpawn})
      if result and result.Instance then
      if result.Instance.Parent.Name == "PlacementArea" then
      CanPlace = true
      ColorPlaceholderTower(Color3.new(0, 1, 0))
      else
      CanPlace = false
      ColorPlaceholderTower(Color3.new(1, 0, 0))
      end

      local x = math.floor(result.Position.X)
      local y = math.floor(result.Position.Y + TowerToSpawn.Humanoid.HipHeight + (TowerToSpawn.PrimaryPart.Size.Y / 2))
      local z = math.floor(result.Position.Z)

      local cframe = CFrame.new(x, y, z) *CFrame.Angles(0, math.rad(rotation), 0)
      TowerToSpawn:SetPrimaryPartCFrame(cframe)
      end
      end)

    • @capistudio867
      @capistudio867 2 роки тому

      cuz for some reason my character doesn't turn even though I did exactly what he said.

    • @aven6150
      @aven6150 Рік тому +1

      @@capistudio867 Open output in the view tab of roblox studio and hit play, it will show you what isn't working by showing a red text about the problem and you can click the red text and send you to a specific part of the script, you can then go into the video at that specific part of the script and see if you messed up anything, I always do that if it messes up, usually some grammar or punctuation error

  • @NebulaBear
    @NebulaBear Місяць тому

    I am very new to this so dont take my words at 100% face value. But i was having an issue with the mobs colliding with the towers still, and the way i figured out how to fix this was to disable anchor on the humanoid root part. I hope this helps some one :)

  • @GuidesAndOther
    @GuidesAndOther 2 місяці тому

    You can also make cancelling placing unit, by chicking if player pressed Q and towerToSpawn exists

  • @PineBloxx
    @PineBloxx 2 роки тому +9

    Let get Gnome to 50K by the end of the year as our Christmas Present! He deserves it!
    #GnomeTo50K

  • @lukiValent
    @lukiValent 2 роки тому +4

    If you want enemies ignore timeout, then you can use this "fix"
    timeout = when the humanoid dont reach the target in 8 seconds, it will go to the next point immediately.
    function enemy.MoveNPC(point, mob)
    local rootpart = mob:WaitForChild("HumanoidRootPart")
    local humanoid = mob:WaitForChild("Humanoid")
    repeat
    wait()
    humanoid:MoveTo(Point)
    until (rootpart.Position - Vector3.new(Point.X, HRP.Position.Y, Point.Z) ).magnitude

    • @lukiValent
      @lukiValent 2 роки тому

      ignore the #paths lmao

    • @connorblox2244
      @connorblox2244 2 роки тому

      or just add more waypoints

    • @mazenez4222
      @mazenez4222 2 роки тому

      HEY luki my script isnt working can u tell me whats wrong pleasee
      local PhysicsService = game:GetService("PhysicsService")
      local ReplicatedStorage = game:GetService("ReplicatedStorage")
      local RunService = game:GetService("RunService")
      local UserInputService = game:GetService("UserInputService")
      local events = ReplicatedStorage:WaitForChild("Events")
      local towers = ReplicatedStorage:WaitForChild("Towers")
      local spawnTowerEvent = events:WaitForChild("SpawnTower")
      local camera = workspace.CurrentCamera
      local gui = script.Parent
      local towerToSpawn = nil
      local canPlace = false
      local function MouseRayCast(blacklist)
      local mousePosition = UserInputService:GetMouseLocation()
      local mouseRay = camera:ViewportPointToRay(mousePosition.X, mousePosition.Y)
      local raycastParams = RaycastParams.new()

      raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
      raycastParams.FilterDescendantsInstances = blacklist
      local raycastResult = workspace:Raycast(mouseRay.Origin, mouseRay.Direction * 1000, raycastParams)

      return raycastResult
      end
      local function RemovePlaceholderTower()
      if towerToSpawn then
      towerToSpawn:Destroy()
      towerToSpawn = nil
      end
      end
      local function AddPlaceholderTower(name)

      local towerExists = towers:FindFirstChild(name)
      if towerExists then
      RemovePlaceholderTower()
      towerToSpawn = towerExists:Clone()



      for i, object in ipairs(towerToSpawn:GetDescendants()) do
      if object:IsA("BasePart") then
      PhysicsService:SetPartCollisionGroup(object, "Tower")
      object.Material = Enum.Material.ForceField
      end
      end
      end
      end
      local function ColorPlaceholderTower(color)
      for i, object in ipairs(towerToSpawn:GetDescendants()) do
      if object:IsA("BasePart") then
      object.Color = color
      end
      end
      end
      gui.Spawn.Activated:Connect(function()
      AddPlaceholderTower("Slinger")
      end)
      UserInputService.InputBegan:Connect(function(input, processed)
      if processed then
      return
      end

      if towerToSpawn then
      if input.UserInputType == Enum.UserInputType.MouseButton1 then
      if canPlace then
      spawnTowerEvent:FireServer(towerToSpawn.Name, towerToSpawn.PrimaryPart.CFrame)
      RemovePlaceholderTower()
      end
      end
      end

      end)
      RunService.RenderStepped:Connect(function()
      if towerToSpawn then
      local result = MouseRayCast({towerToSpawn})
      if result and result.Instance then
      if result.Instance.Parent.Name == "TowerArea" then
      canPlace = true
      ColorPlaceholderTower(Color3.new(0,1,0))
      else
      canPlace = false
      ColorPlaceholderTower(Color3.new(1,0,0))
      end
      local x = result.Position.X
      local y = result.Position.Y + towerToSpawn.Humanoid.HipHeight + (towerToSpawn.PrimaryPart.Size.Y / 2)
      local z = result.Position.Z
      local cframe = CFrame.new(x,y,z)
      towerToSpawn:SetPrimaryPartCFrame(cframe)
      end
      end

      end)

    • @lukiValent
      @lukiValent 2 роки тому

      @@mazenez4222 does the script gives any error?

    • @typicalaverage
      @typicalaverage 2 роки тому

      @@lukiValent yo Luki, i tried using the code, BUT it doesnt seem to work in the mob move part, is there a fix for that? (It gives an error that mobmove isnt a parent of "Basic" (custom) zombie)

  • @badmonkey3119
    @badmonkey3119 2 роки тому +1

    Gnome code I don't think you will see this but thx so much for helping me create my first legitimate game ever at a age of 13
    I am so close to being finished and releasing it and I am so happy with the quality of my game.
    I have 15 different towers, 11 different zombies/monsters and 4 different maps.
    The game is called Apex tower defense and will be released in June.
    Thx so much for helping me make my dream game come true

  • @CurtyRagsdude
    @CurtyRagsdude Рік тому +2

    Since my grandpa's birthday and my birthday are 1 week apart, this episode was published on my birthday and the very next episode was published on my grandpa's birthday 😁

  • @guxango8630
    @guxango8630 2 роки тому +3

    Can you make a model with all the towers so we can take your towers?

  • @user-lv1ws3lp2q
    @user-lv1ws3lp2q 4 місяці тому +3

    i actually have a problem that it is says that setprimaryPartCframe is not a valid member of workspace

  • @ExstraLuck
    @ExstraLuck 11 місяців тому

    This guy deserves 2 mil subs!

  • @Wazzalish
    @Wazzalish 2 роки тому +6

    To get damage to work on a tower for now you need to change in the testing tower script (If your have your script in the tower) change workspace.TowerName.HumanoidRootPart to workspace.Tower.TowerName.HumanoidRootPart then damage should work!

    • @bobkerman8930
      @bobkerman8930 2 роки тому

      "If u have ur script on ur tower" wait where i put it?

    • @jjmyclark7354
      @jjmyclark7354 8 місяців тому

      I don’t understand

  • @nexoshez
    @nexoshez 2 роки тому +5

    Can the next video have mobile support and/or console support? cause my friends cant access much - Fixed!
    heres if you need mobile support (put in GameController)
    function TouchLongPress(TouchPositions, state, gameProcessedEvent)
    if canPlace then
    spawnTowerEvent:FireServer(towerToSpawn.Name, towerToSpawn.PrimaryPart.CFrame)
    RemovePlaceholderTower()
    end
    end
    UserInput.TouchLongPress:Connect(TouchLongPress)

    • @sukiyaki4623
      @sukiyaki4623 2 роки тому

      how would i do this?

    • @nexoshez
      @nexoshez 2 роки тому

      @@sukiyaki4623Put the script part under the UserInputService.InputBegan function. this is to place towers on mobile

  • @derektrout1958
    @derektrout1958 Рік тому

    how do you make a humanoid like the slinger do damage because mine does damage but when i press the place it doesnt i know this was made a long time ago but if u see this do u have an explanation but other than that i love your tuts

  • @donofr666
    @donofr666 Рік тому +4

    i have a problem when i click where i want to place my tower it just go in the original spot that it was even the other tower go there so it stack in one place i dont konw if its because i dont use a humanoid
    edit: i solved it it was because the primary part is inside the other part

    • @TheOhioMonkey
      @TheOhioMonkey 3 місяці тому

      how did u solve it?

    • @donofr666
      @donofr666 3 місяці тому

      @@TheOhioMonkey i changed the primary part to be the one with the other one in it

    • @youraveragecuber101
      @youraveragecuber101 12 днів тому

      can i pls see your code i am really stuck on how to fix it

  • @karleegaming8482
    @karleegaming8482 Рік тому +3

    Can someone help me? My tower is working perfectly fine until I place it into the "Towers" folder. Once I do that and spawn the tower it stops printing everything it is being told to do and doesn't damage the enemy.

  • @akiprox7
    @akiprox7 Рік тому

    Bro this is amazing! I just got an bug where everything is normall just when the tower is placed it kinda flied up in the sky and it's not the HipHeight problem!

  • @Mr.Watermeloncat12341
    @Mr.Watermeloncat12341 Рік тому

    ik these are tutorials but like its still fun to watch even when your not using it, amazing videos

  • @zFrost
    @zFrost Рік тому +6

    (Solved, note for future me to remember this comment if it happens again)
    When i press the spawn button my tower gets cloned in the place where i left it instead of following my mouse, any ideas why this isn't working?
    I've tried using a mesh part as my tower and a humanoid NPC as a tower and they both act the same, they work exactly like this: 7:17
    My code is the same as the video except everything past fixing height offset
    Solution: I checked the video 3 times, and just now i realized what was wrong in the game controller script:
    local function AddPlaceholderTower(name)
    local towerExists = towers:FindFirstChild(name)
    if towerExists then
    local towerToSpawn = towerExists:Clone()
    towerToSpawn.Parent = workspace.Towers
    end
    end
    All you have to do it delete the "local" in the third towerToSpawn

    • @umm134
      @umm134 Рік тому +1

      TYSM!

    • @cakecheese2895
      @cakecheese2895 Рік тому

      You are an angel

    • @reis1325
      @reis1325 Рік тому +1

      Holy Bro I love you thank you you just saved my life and like 35 hours of trying to find out the bug

    • @i_beez
      @i_beez Рік тому

      *I tried to fix 1 hour, THANKS*

    • @slurpybanana
      @slurpybanana Рік тому +3

      It still spawns it in the placeholder position and not where i clicked

  • @TheNewSetSai
    @TheNewSetSai 2 роки тому +4

    this series is actually good, thank you so much!
    also one question, how do you keep the item with the tower? i tried placing mine and it was only the character without the weapon

    • @TheWatcherYT
      @TheWatcherYT 2 роки тому +1

      did you weld the character to the weapon? Use a motor 6d or weldconstraint and make the part0 attachment the arm and the part1 attachment the weapon, then it should appear with the weapon.

    • @TheNewSetSai
      @TheNewSetSai 2 роки тому

      @@TheWatcherYT thank you for the information my guy, that is what I just needed

    • @AltGaming685
      @AltGaming685 2 роки тому

      @@TheWatcherYT how?

    • @TheWatcherYT
      @TheWatcherYT 2 роки тому

      @@AltGaming685 Go look up a rig edit tutorial because i don't know how i can make this clearer.

    • @PickleGobler
      @PickleGobler 2 роки тому

      @@TheWatcherYT cant we just use a tool that has no scripts?

  • @Chips-zx6pt
    @Chips-zx6pt 2 місяці тому

    👍Good

  • @davidias6922
    @davidias6922 8 місяців тому

    You are nice!

  • @BryAstronaut
    @BryAstronaut Рік тому +4

    12:06 gnome jumpscare

  • @JaxAttackRBX
    @JaxAttackRBX 2 роки тому +3

    I'm still having problems after 16:11 I have two problems. 1. My tower isn't dealing damage to the enemies 2. Even after the script was perfect my tower got stuck in the ground as placing it.

    • @roystopmotion6150
      @roystopmotion6150 2 роки тому

      No.2 me too..

    • @bobkerman8930
      @bobkerman8930 2 роки тому +1

      Edit: i actually rewrote the whole entire series and it worked u should try it and now im on episode 18 sofar sogood

    • @ratcraftplayzrblx6942
      @ratcraftplayzrblx6942 2 роки тому

      no.2 im also stuck on that pls let me know if u find a solution

    • @JaxAttackRBX
      @JaxAttackRBX 2 роки тому

      @@ratcraftplayzrblx6942 I figured out the issue. I think it's because I did not set the hipheight properly. If that's not the case, then I would rewatch the video a couple of times and check over your script as you're listening

    • @ratcraftplayzrblx6942
      @ratcraftplayzrblx6942 2 роки тому

      @@JaxAttackRBX thank you but i kind of gave up on the idea bc it was a lot of work for me only but ty.

  • @filipous11
    @filipous11 9 місяців тому

    People, if the "Tower" is still approaching the camera, turn off canCollide and canQuery, it should help. It helped me.

    • @Bloxxer0908
      @Bloxxer0908 4 місяці тому +1

      words cannot describe how thankful i am for this simple comment.

  • @HurelyDev
    @HurelyDev 2 роки тому +7

    Good Tip: If You Want Your Towers To Walk Towards A Enemy, Use This Inside The Script: local tower = script.Parent.Parent
    local mobs = workspace.Mobs
    local function FindNearestTarget()
    local maxDistance = 100
    local nearestTarget = nil
    for i, target in ipairs(mobs:GetChildren()) do
    local distance = (target.HumanoidRootPart.Position - tower.HumanoidRootPart.Position).Magnitude
    if distance < maxDistance then
    nearestTarget = target
    maxDistance = distance
    end
    end

    return nearestTarget
    end
    function moveToTarget()
    local Target = FindNearestTarget()

    if Target then
    script.Parent.Parent.Humanoid:MoveTo(Target.HumanoidRootPart.Position)
    script.Parent.Parent.Humanoid.MoveToFinished:Wait()
    if Target.Humanoid then
    Target.Humanoid.Health -= 100
    wait(1)
    script.Parent.Parent.Humanoid.Health = 0
    else
    script.Parent.Parent.Humanoid.Health = 0
    warn("Humanoid Doesnt Exist")
    end

    else
    script.Parent.Parent.Humanoid.Health = 0
    end
    end
    script.Parent.Parent.Humanoid.Died:Connect(function()
    warn(2)
    script.Parent.Parent:Destroy()
    end)
    while true do
    task.wait(0.1)
    moveToTarget()
    end

    • @devdeepy5665
      @devdeepy5665 2 роки тому +1

      hey it seems like you good at script but can you help me something?
      when i place 1st tower, you cannot walk to through tower
      but when i place another tower, you can walk
      i think physic service having delay so do you have a script to fix it?

    • @HurelyDev
      @HurelyDev 2 роки тому

      @@devdeepy5665 I'm also having a physics service bug where I cant walk through them even when I wait

    • @devdeepy5665
      @devdeepy5665 2 роки тому

      @@HurelyDev fixed the problem but OnPlayerAdded is glicthy

    • @TheWatcherYT
      @TheWatcherYT 2 роки тому +1

      Use a "player.CharacterAppearanceLoaded", it works for me since the character being added takes a while so this waits until it loads.

    • @joshyh4vidz
      @joshyh4vidz 5 місяців тому

      my tower isnt spawning and there is no errors please help

  • @PipoPavan
    @PipoPavan Рік тому +5

    17:14 if / 2 doesnt work . Try using + 1 :)

  • @pinosicoboy
    @pinosicoboy Рік тому

    hopefully it worksrep you helped me

  • @Kurtrin
    @Kurtrin 7 місяців тому

    Dang this is why i wanted to do computee science