This is what i did so far:
if math.random(1,4) == 1 then moveforward() end if math.random(1,4) == 2 then movebackwards() end if math.random(1,4) == 3 then moveleft() end if math.random(1,4) == 4 then moveright() end
But yet when i run the code it won't run even if i add a wait() when i added a wait() it worked once but after that it didnt move after i ran the script again, i even tryed making a math random that loops with a wait(2) yet it still wont move or execute its functions, functions are just a cframe for moving it, and a print to know if it executed or no
while true do mr = math.random(1,4) wait(2) end
Heres the code of the math random that loops
Add a wait loop so it constantly checks. If stamens only check once
while wait(3) do if math.random(1,4) == 1 then moveforward() end if math.random(1,4) == 2 then movebackwards() end if math.random(1,4) == 3 then moveleft() end if math.random(1,4) == 4 then moveright() end end
Sorry for the bad format, I’m on mobile
I am confused why dont u use elseif, Here is the fixed version for u Ill explain the bugs
while true do wait (1) -- u should add this so it infinitely loops local Number = math.random(1,4) if Number == 1 then moveforward() elseif Number == 2 then -- use elseif as it also gives alternate conditions, movebackwards() elseif Number == 3 then moveleft() elseif Number == 4 then moveright() end end
i am sorry if this wasnt the outcome u were expecting, i didnt kinda understand what u wanted in the script