#need help with scripting @bollaside

234 messages · Page 1 of 1 (latest)

opal pewter
#

so basically I want the mobs to spawn in without them colliding with each other

#

@coarse spruce

coarse spruce
#

alright you gotta post the script tho cuz I do not remember it by heart (surprising, ik)

opal pewter
#
local mob = {}

function mob.Move(mob, map)
    local humanoid = mob:WaitForChild("Humanoid")
    local waypoints = map.Waypoints
    
    for waypoint=1, #waypoints:GetChildren() do
        humanoid:MoveTo(waypoints[waypoint].Position)
        humanoid.MoveToFinished:Wait()
    end
    
    mob:Destroy()
    
end

function mob.Spawn(name, quantity, map)
    local mobExists = ServerStorage.Mobs:FindFirstChild(name)
    
    if mobExists then
        for i=1, quantity do
            task.wait(0.5)
            local newMob = mobExists:Clone()
            newMob.HumanoidRootPart.CFrame = map.Start.CFrame
            newMob.Parent = map.Mob

            coroutine.wrap(mob.Move)(newMob, map)
        end
        
    else
        warn("Requested mob does not exist:", name)
    end
end

return mob```
#

here

#

the mobs are spawning in just fune

#

fine(

#

fine*

#

I dont want them to collide with each other

#

thats it

coarse spruce
#

Ok so what you wanna do is make a CollisionGroup, make it so that mob group does not collide with mob group (itself) and set their parts to it

#

you'll need to make a variable for the PhysicsService

#

at the top

#

@opal pewter

opal pewter
#

so

#

to recap it, I gotta first go to model and get on the Collision groups?

#

and from there

coarse spruce
#

Hm?

#

nope

#

we're just doing everything in the script

opal pewter
#

oh

coarse spruce
#

so make a PhysicsService variable (it's just like ServerStorage but with PhysicsService instead)

#

tell me when done

opal pewter
#

like this?

coarse spruce
#

yep

#

now under mob variable, you'll want to use PhysicsService:CreateCollisionGroup(name) to create a collision group

#

replace name with the group name in quotes

opal pewter
#

ok

coarse spruce
#

it can be anything

#

but I'd recommend with something you'll later understand like "Mob"

opal pewter
#

could u help me locate where to place it? as I mentioned before I have no damm idea about scripting

coarse spruce
#

below local mob...

opal pewter
#

oh

#

alright

coarse spruce
#

and below that you're gonna want to put PhysicsService:CollisionGroupSetCollidable(name, name, false)

opal pewter
coarse spruce
#

where you'll replace name with your group anem

coarse spruce
#

in parentheses is supposed to be the group name in quotes

#

by just putting mob you're referencing to the variable above, that's not what you want

opal pewter
#

oh

#

then what should I write

coarse spruce
#

it's supposed to be something like "Mob"

opal pewter
#

OHH

#

bro you're actually cool

#

I am actually understanding things

#

for the first time

coarse spruce
#

Nice

opal pewter
#

so inside the bracket

#

I write

#

"Mob"

#

right?

coarse spruce
#

yes

opal pewter
#

now?

coarse spruce
#

don't forget the quotes

#

and capital letters matter

opal pewter
#

PhysicsService:CollisionGroupSetCollidable(name, name, false)

coarse spruce
#

oh and leave false as is

opal pewter
#

ok

#

and there are two names

coarse spruce
#

yes, they're all the same

opal pewter
#

one will be Mob as per of the createdCollision group

#

what am I supposed to write then? Mob in both

#

?

coarse spruce
#

same in all 3 places

opal pewter
#

ok

#

like this?

#

also my folder is named Mobs

coarse spruce
#

nope, you forgot the quotes

opal pewter
#

Oh

#

my bad

#

wait what do u mean by quotes

#

like this?

#

☠️

coarse spruce
#

yes

opal pewter
#

oh

coarse spruce
#

just like that

opal pewter
#

works fine?

#

alright

coarse spruce
#

not yet

opal pewter
#

I was scared

opal pewter
coarse spruce
#

we only created the group and set if 2 parts have the same group they don't collide

coarse spruce
opal pewter
#

ok

#

it doesnt matter?

coarse spruce
#

so now

#

nope

opal pewter
#

ok

coarse spruce
#

so now we're gonna modify the mob.Spawn function

opal pewter
#

Ok

#

yeah

coarse spruce
#

we're gonna write a loop to make every part of the mob the group we need, below line 27 make a new line

opal pewter
#

because when I do this, the mob doesnt spawn or they fall down when they are being spawned

#

so I think now this will be resolved

#

I guess

coarse spruce
#

ok that's weird

#

but yeah

opal pewter
coarse spruce
#

yes

opal pewter
#

basically I give a space in line 27

#

?

coarse spruce
#

below it

opal pewter
#

ok

coarse spruce
#

ok in detail, click at the end of line 27 and press enter

#

lol

opal pewter
#

done

#

ik

#

my bad

#

XD

coarse spruce
#

now you're gonna want to type this cryptic line: for _, obj in newMob:GetDescendants() do and press enter

#

so what this does is it loops through every instance inside of the mob model

opal pewter
#

ok

#

so should I copy exactly what you stated

coarse spruce
#

and what it does with each obj is should be at line 29

opal pewter
#

?

coarse spruce
opal pewter
#

like this?

coarse spruce
coarse spruce
opal pewter
#

did

coarse spruce
#

it should look something like this

for ....
  (your cursor here)
end
opal pewter
#

yeah yeah

#

it is

coarse spruce
#

alright

#

now here you're gonna want to check if the instance is an actual part that we can assign the group to

#

because if it's an image for example we can't do that

opal pewter
#

ofc

coarse spruce
#

and to check it you type if obj:IsA("BasePart") then and press enter

opal pewter
#

done

#

on line 30 rn

coarse spruce
#

now there, the last line (not at the last line of the script fyi), you assign the collision group

#

using obj.CollisionGroup = name

#

where once again, name is the group name

opal pewter
#

i give this obj.CollisionGroup = name on line 30?

coarse spruce
#

yes

#

but replace name

#

with the mob group name

opal pewter
#

ok

coarse spruce
#

now show what the script looks like

opal pewter
#

Mob group name is Mobs

#

so should I write mobs?

coarse spruce
#

nope, it was something else

#

the same as you did on lines 4-5

#

that same name

opal pewter
#

just mob?

coarse spruce
#

same you did on lines 4 and 5

opal pewter
#

okay

#

mob then

#

works?

coarse spruce
#

you forgor the quotes again

opal pewter
#

oh

#

its green

#

good to go?

coarse spruce
#

yes

#

yes

opal pewter
#

ok

#

now?

coarse spruce
#

it should work

#

ideally

opal pewter
#

I give run?

coarse spruce
#

yeah

opal pewter
#

yep wtf

#

you're the goat bro

#

IT WORKS

#

BRO

#

NAHH

coarse spruce
#

Gg

opal pewter
#

Bolaside, is there anyway I could vouch you for helping me out?

#

I want you to get promoted ASAP

coarse spruce
#

Nah xd

opal pewter
#

okay so If I run into

distant mangoBOT
#

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

opal pewter
#

any problems again

#

could I ping u?

coarse spruce
#

yeah sure

opal pewter
#

( if you dont mind )

#

okay bro

#

thanks a lot

coarse spruce
#

No problem haha

opal pewter
#

could I get you added? I've become a fan of you now

#

you've explained it splendidly

#

thank you so much again

coarse spruce
#

Mark this as solved btw so people don't think it's unsolved

opal pewter
#

oh

#

bet

coarse spruce
opal pewter
#

alright, if I run into any sort of problems I'll make a thread and ping you

#

okay thanks

#

have a great day!

coarse spruce
#

Mhm cya

#

you too

opal pewter
#

@coarse spruce so sorry to disturb you but how'd I turn of player collisions off because it works but I am still colliding with my own mobs

coarse spruce
#

wdym?

opal pewter
#

I am colliding with the mobs

#

for some reason..

#

but the mobs arent colliding with each other

#

okay nevermind

#

I'll work on this on my own

#

sorry

coarse spruce
opal pewter
#

@coarse spruce alright so uh, I've tried this and this will def not work I think, I want the players not to collide with the mobs now

coarse spruce
#

that is actually VERY close

#

change "Player" to "mob"

opal pewter
#

Oh fr?

#

damm

opal pewter
coarse spruce
#

also add player.CharacterAppearanceLoaded:Wait() below line 6

coarse spruce
opal pewter
#

fine?

coarse spruce
opal pewter
#

with what

#

swap them with what

#

should I just delete 6 and 7

coarse spruce
#

swap them

#

make line 6 be line 7 and line 7 be line 6

#

just select line 6

opal pewter
#

OHH

coarse spruce
#

and press alt + ↓

opal pewter
#

ok

#

done

#

now what

coarse spruce
opal pewter
#

W

#

works