#random numbers
1 messages · Page 1 of 1 (latest)
** You are now Level 2! **
just use math.random again
wdym
Dont set a variable for math.random
Just go straight out
Math.random(x,x)
@stable oxide
local TweenInfo = TweenInfo.new(2, Enum.EasingStyle.Circular, Enum.EasingDirection.InOut, -1, true, 0)
local model = game.Workspace["cube system"].cubes:GetChildren()
for _, cube in pairs(model) do
local tween = TweenService:Create(cube, TweenInfo, {
Rotation = cube.Rotation + Vector3.new(0,180,0),
Position = cube.Position + Vector3.new(math.random(-10,10),0,math.random(-10,10))
})
tween:Play()
end```
when the script runs
the random vector position doesnt change each time the tween is ran
i wanna make it so the random vector position DOES change
so its not doing the same thing every time
if that makes sense
Like you only want the cube to go to the position once and not repeat the previous position?
yes
exactly
a new position every time
HELP 💔
Ok I just woke up from my 10 hour sleep
Its easy
Make a array
And add the random number in the array so u can checm if that number is used or not
what would that look like
Local array={}
array.x={}
array.z={}
-- script --
local array={}
array.x={}
array.z={}
local cube=script.parent
local cubepos=cube.Position
function check(axis,number)
for i=1,#axis do
if axis[i]==number then
return false
end
end
return true
end
local range = 10
function recursive(times)
if times==0 then
return true
end
for i=0,range*2 do
local x =math.random(-range,range)
local z=math.random(-range,range)
if check(array.x,x) and check(array.z,z)then
cube.Position=cubepos+Vector3.new(x,0,z)
table.insert(array.x,x)
table.insert(array.z,z)
if recursive(amount-1) then
return true
end
end
end
return false
end