Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Anyone know how to use math.random() for a CFrame position?

Asked by
Xoqex 75
9 years ago

So I'm trying to make some ice that moves around, so I unanchored it, added in a body gyro and velocity and position. I can't use the ~~~~~~~~~~~~~~~~~ math.random() ~~~~~~~~~~~~~~~~~ to change the velocity force so it moves around. Any help would be appreciated.

2 answers

Log in to vote
0
Answered by 9 years ago

You could use the math.random method for a Vector3 method, for it will choose a random Number value for the Vector3 argument(s), here's an example of what I mean;

local Part = game.Workspace:WaitForChild("Part") --Here's a random part
Part.CFrame = CFrame.new(Part.Position + Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2))) --And as you'll see, it'll switch positions each time :D

Sadly, I'm not too sure you can use the math.random method for a CFrame method, but, I'm just not sure, doesn't mean it may not work in a CFrame method. :) Hope this helped!

Ad
Log in to vote
-1
Answered by 9 years ago

You can probably math.random each X,Y,Z value of Velocity

so something like

while true do
    script.Parent.Velocity.X = math.random(something,something)
    wait(something)
    script.Parent.Velocity.Y = math.random(something,something)
    wait(something)
end

Answer this question