Moldard
(Moldard)
March 13, 2021, 9:26am
#1
Hello ! I a beginner on lua, and I have a little question !
What do you want to achieve? Keep it simple and clear!
I want to have a random movement for my dummy.
What is the issue? Include screenshots / videos if possible!
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)
LuaCoold
(lua)
March 13, 2021, 9:29am
#2
Does it atleast work with a normal part?
Moldard
(Moldard)
March 13, 2021, 9:44am
#3
No 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?
LuaCoold
(lua)
March 13, 2021, 9:46am
#5
it can be either.
or so.
but idk
Moldard
(Moldard)
March 13, 2021, 9:47am
#6
i try it on a normal script, but yes, same problm, no difference
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
LuaCoold
(lua)
March 13, 2021, 9:51am
#8
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
LuaCoold
(lua)
March 13, 2021, 9:56am
#9
have you tried the suggestion / script I sent you?
Moldard
(Moldard)
March 13, 2021, 9:58am
#10
yes, i try it both of your solution. And, nothing
i dont sure, but maybe the problm is the dummy … i try to change it
Moldard
(Moldard)
March 13, 2021, 10:00am
#11
OK ! So the problm is the dummy, i dont know why … Thank you, and sorry …
LuaCoold
(lua)
March 13, 2021, 10:02am
#12
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)
LuaCoold
(lua)
March 13, 2021, 10:03am
#13
Please provide the errors from dev console.
Moldard
(Moldard)
March 13, 2021, 10:03am
#14
oh ok, i try it right now, thanks
Moldard
(Moldard)
March 13, 2021, 10:07am
#15
I got this. But, you know, i find the problem ( the dummy ) so i think its ok
LuaCoold
(lua)
March 13, 2021, 10:08am
#16
nice job fix that and it might work!
1 Like
LuaCoold
(lua)
March 13, 2021, 10:09am
#17
can I ask a question? what are you using this for though?
Moldard
(Moldard)
March 13, 2021, 10:12am
#18
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
LuaCoold
(lua)
March 13, 2021, 10:14am
#19
you know you can use Humanoid | Documentation - Roblox Creator Hub ! better way of doing what your trying. anyways im going to sleep gn!
Moldard
(Moldard)
March 13, 2021, 10:15am
#20
ok thank you ! i will see it later, have a good night !