So I’m making a dice game But I had some trouble deciding how the dice should roll. I eventually decided The dice should float up and roll themselves in the air without actually rolling on the ground. I determined to do this by inserting a body velocity into the dice that with hover them in the air. I understand how body velocities work but I’m not so sure about rotational velocities. How would I go about making the dice roll in the air in random directions?
You should use a BodyAngularVelocity, and randomize each value in the Vector3.
Kinda like this:
local vel = Instance.new('BodyAngularVelocity') vel.Parent = (the dice basepart or primarypart) vel.AngularVelocity = Vector3.new(math.random(1,180),math.random(1,180),math.random(1,180))
It doesn’t quite seem to be random Both the dice look like they rotate at the same angle.
Try using Random.new() with different seeds. For example you could use tick() for one seed, and tick()+100 for the other one. Since you’re probably rolling the dice at the same time, both of the random seeds are the same since they occur on the same tick.
tick() work? I’m not quite that advanced yet
tick() is just the amount of seconds that have passed since 1970, January 1st. If you use this seed twice at the same time it will have the same result, which im guessing happened with your dice?
If that doesn’t work pls show me the code you used.
Yes, the dice do roll in the same direction at the start although it does appear to be random. The player’s may be annoyed that it looks like the dice start off rolling the same direction. I’ll try the
tick() to see if that makes it look better.
Whenever I try to print
Random.new([random number]) it returns the string
edit: I’m not quite familiar with
local rand = Random.new(tick()) print(Random:NextInteger(min,max))
Think of Random.new() as a service even though it isn’t. NextInteger would be a function of the service.
local MinimumNumber = 1 local MaxNumber = 10 local RandomService = Random.new() print(RandomService:NextInteger(MinimumNumber, MaxNumber) — Anything between 1 - 10 will be printed.
Thank you. One question though, what is the difference between using
Random is more random than
math.random(). Also, if you use
Random:NextNumber(), you get decimals also.