Help for move to random point

Hello ! I a beginner on lua, and I have a little question !

  1. What do you want to achieve? Keep it simple and clear!
    I want to have a random movement for my dummy.

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried a lot of different solution, but for this one, i really dont understand why isnt working.

local dummy = script.Parent
local dummyHumanoid = dummy.Humanoid
local dummyRoot = dummy.HumanoidRootPart
local dummyPos = dummyRoot.Position
local destination = Vector3.new(math.random(1,5), 0, math.random(1,5))
local base = dummy.Parent.Terrain


dummyHumanoid:MoveTo(destination)

Does it atleast work with a normal part?

No :confused: its a local script btw. I dont know why its not working xd

Wait why is it in a localscript? Shouldn’t it be a regular script?

it can be either.
or so.
but idk

i try it on a normal script, but yes, same problm, no difference :confused:

Maybe try

dummyHumanoid:MoveTo((dummyPos + destination))

Instead of

dummyHumanoid:MoveTo(destination)

Since I don’t think it’s working because the dummy can’t reach y 0

instead of destination you can do something like

local X = math.random(0,0)
local Y = math.random(0,0)

and add in
PartNameHere.Position = Vector3.new(x, 0, z)
try making something with that.

sorry if it doesnt work its like 4 am for me rn

heres another way that describes it better but in the way i do

have you tried the suggestion / script I sent you?

yes, i try it both of your solution. And, nothing :confused:
image
i dont sure, but maybe the problm is the dummy … i try to change it

OK ! So the problm is the dummy, i dont know why … Thank you, and sorry …

your doing it wrong this is how you do it

local dummy = script.Parent
local dummyHumanoid = dummy.Humanoid
local dummyRoot = dummy.HumanoidRootPart
local dummyPos = dummyRoot.Position
local X = math.random(0,1)
local Z = math.random(0,1)

wait(10)
dummyHumanoid.Position = Vector3.new(X, Z)

Please provide the errors from dev console.

oh ok, i try it right now, thanks

image
I got this. But, you know, i find the problem ( the dummy ) so i think its ok

:+1: nice job :slight_smile: fix that and it might work!

1 Like

can I ask a question? what are you using this for though?

i want to make a npc move randomly like zombie in dayz ( they walk randomly ) and after, i will do a box collision for move to the player

you know you can use Humanoid | Documentation - Roblox Creator Hub ! better way of doing what your trying. anyways im going to sleep gn!

ok thank you ! i will see it later, have a good night !