#NPC not moving.

177 messages · Page 1 of 1 (latest)

modern herald
#

Hey, im trying to make an npc move to these different nodes in an area, unfortunately it does not work, and does not give an error.
Script:

local Humanoid = Character.Humanoid
for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
    Humanoid:MoveTo(v.Position)
    Humanoid.MoveToFinished:Wait()
end```

Inside the NPC:

Any help?
lapis ermine
#

You have parts to move in Nodes? If yes, Nodes is a folder or model?

lapis ermine
lapis ermine
#

moveto have two arguments, he have only one

modern herald
#

still doesnt work doe

#

its a script if that matters

#

no

eager valve
#

you dont need two params for moveto

modern herald
#

it works when I use an NPC from load chaarcter pro

lapis ermine
#

one minute

lapis ermine
eager valve
#

move to has 1 param which is a vector3

#

asking for the position

lapis ermine
#

then why its is doesnt moving?

eager valve
#

here is an example of me using a moveTo for my td game ```lua
function module.Move(Mob)
local hum = Mob:WaitForChild("Humanoid")
local waypoints = workspace.Map.Points.Waypoints
local hrp = Mob:WaitForChild("HumanoidRootPart")

for i= 1, #waypoints:GetChildren() do
    repeat 
        hum:MoveTo(waypoints[i].Position)
        hum.MoveToFinished:Wait()
    until (hrp.Position - Vector3.new(waypoints[i].Position.X, hrp.Position.Y, waypoints[i].Position.Z)).magnitude <= 1 or hum.Health <= 0
    
end
base.Humanoid.Health -= hum.Health
Mob:Destroy()

end

#

moveto takes one parameter

modern herald
#

this is the game

eager valve
lapis ermine
#

then create character again and paste script to him if the scriptis in it

modern herald
#

what

lapis ermine
#

wait

#

where your script is located

#

into character?

modern herald
#

i tried it on a script and localscript

eager valve
#

are i just made one and it worked but it wasnt working until unanchored all the parts

modern herald
#

there is a weld

eager valve
#

ok?

#

are any of the parts anchored though?

#

pretty much

modern herald
#

nothing is really anchored

#

even if i delete the things i cant unanchor it still doesnt work

lapis ermine
eager valve
#

are you using a normal model

#

can you show all of the parts inside the character

modern herald
compact zincBOT
#

studio** You are now Level 2! **studio

lapis ermine
#

uh

#

its is a cat

modern herald
#

yeah but does it matter

eager valve
#

c a t

modern herald
#

i just want it to move around those thingies

#

nodes

cedar fiber
# modern herald

if you're making a raise a maxwell game i actually suggest you make it move in random positions of a big plane.

#

adds more randomness

#

isn't very hard you get the size of the plane, then use math.random() on all the properties

modern herald
#

yeah but im not very good at scripting

#

so idk how to do any of that

cedar fiber
#

Devforum is helpful.

eager valve
#

you should make all of the nodes' names be 1, 2, 3...

#

because then the math.random would work

cedar fiber
#

Or you can rename them using a script so you don't have to do it manually.

eager valve
cedar fiber
#
for _,part in pairs(Nodes:GetChildren()) do
    part.name = tostring(_)
end
cedar fiber
eager valve
# cedar fiber ?

you can do that but then you have to yeild everything else from happening until thats done

eager valve
#

look at it in the long run

cedar fiber
eager valve
#

how is he gonna know where the cat is

cedar fiber
modern herald
#

i think ill just pay someone to do it because its doing more questions than answers

eager valve
#

if the node's name is different every time

cedar fiber
#

It's running through a pair function

eager valve
cedar fiber
eager valve
#

ok

cedar fiber
#

What do you mean

eager valve
#

lemme make something and i'll show u

modern herald
#

while ur at it can u make me a replica of what im trying to do and make it work kthx

cedar fiber
#

I'm not gonna write full code for you but I can fix your code.

modern herald
cedar fiber
#

Please send it lmao

cedar fiber
#

Because you can't use MoveTo unless it's a humanoid character

#

A character requires a HumanoidRootPart, and head

#

That just could be your problem.

modern herald
#

how do i rig it

#

or how do i add a hrp

eager valve
cedar fiber
#

Yeah. So just go with that.

#

😄

cedar fiber
#
#

Heres a helpful video

#

Watched it myself about a year ago and was simple

#

Another thing you can do to make it go to nodes is by tweening the cat.

#

This doesn't require a character and is more simple

#

Although, it won't look as charactery

modern herald
#

I havent touched anything. just opened rigedit

cedar fiber
#

Great. So it is rigged. That's a step

cedar fiber
modern herald
#

idk what that means lol

cedar fiber
#

That's not what it means.

modern herald
#

it already has a humanoid

#

i got this code from someone

local children = Nodes:GetChildren() -- returns a table of Instances
local new = children[math.random(1, #children)] -- Picks a Random instance

if new then -- if Instance
Hum:MoveTo(new.Position) -- MoveTo Instance
Hum.MoveToFinished:Wait() -- Yields code for roughly 8 Seconds
end
end

PickRandom(Character.Humanoid)```
ill test it now
cedar fiber
compact zincBOT
#

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

cedar fiber
modern herald
#

yours

cedar fiber
#

Not the model

modern herald
#

wdym the cat

cedar fiber
#

You can't tween a whole model.

#

jesus christ

modern herald
#

so the body

cedar fiber
#

the maxwell part

modern herald
#

i renamed it

compact zincBOT
#

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

modern herald
cedar fiber
#

Remove the Humanoid

#

And remove the Humanoid identifier in the script

#
local Character = script.Parent.Body

local TweenService = game:GetService("TweenService")

for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
    spawn(function()
         TweenService:Create(Character, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = v.Position}):Play()
         wait(3) --waits til the next movement
    end)
end
modern herald
#

he went to a part and just stays there

cedar fiber
#

Yeah, so it works

#

You just need to loop it now

modern herald
#

yeah but i want him to move around

#

oh

#

ok

cedar fiber
#

I can do that

modern herald
#

oke

cedar fiber
#
local Character = script.Parent.Body
local TweenService = game:GetService("TweenService")

local movementwait = 3 -- time until next movement

while wait(movementwait) do
    local allpos = {}
    for i,v in pairs(game.Workspace.Nodes:GetChildren()) do
        if v.Position ~= Character.Position then
            table.insert(allpos, v.Position)
        end
    end
    local currpos = allpos[math.random(1, #allpos)]
    TweenService:Create(Character, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = currpos}):Play()
end
#

try this

#

@modern herald

modern herald
#

ok

#

it do be working

#

but he flops around all over the place

#

can i anchor him

cedar fiber
#

Yes

#

Anchoring won't mess with the tweens

#

Please mark your thread as Solved. Happy to help.

modern herald
#

ive got 1 little problem

#

the billboard gui over his head doesnt follow him

#

also hes very fast

#

how can i slow him down

cedar fiber
#

You have to put the billboard gui on the body not the model

modern herald
#

thanks

cedar fiber
#

You see where it says 1

#

Change it to the speed you want

modern herald
#

tyvm

#

wait

#

what if i want to do a random amount

#

like 1-5

cedar fiber
#

math.random(1, 5)

modern herald
#

thank you!!

cedar fiber
#

Yep

#

To prevent more people saying stuff mark it as solved

#

So people know you don't need help with the npc moving

modern herald
#

uhh so now it just doesnt wait at the node do i increase the wait time

#

like he gets to a part and then instanttly starts moving again

cedar fiber
#

do this

#

math.random(1, movementwait)

cedar fiber
modern herald
#

thank you <3

cedar fiber
#

No problem

cedar fiber
#

Technically you can tween a model but you have to do it in a weird way

#

nope lmao

#

setting the primary part's position everytime the tween starts

#

so it moves everything its just more manual