Reliable way to give model:scaleto() a random value?

really simple question I have for the dev-forum; and I haven’t written the script for it, but what would be the most reliable way to model:scaleto() use random values such as,

math.random(0.8, 1.3)

This is how you might approach this.

  1. Generate a random number between 0.8 and 1.3.
  2. Scale the model uniformly on all axes by the random number to apply the random scale.

scale the model using all axes? Im trying to use model:scaleto() for simplicity.

This is what I mean, ScaleFactor is the random generated number.

model:ScaleTo(Vector3.new(scaleFactor, scaleFactor, scaleFactor), 1)

Oh I see, thank you; Ill try this to see what it has

1 Like

Might I ask what the “1” does in the line of code; I tested it and it seems to return an error,
“Unable to cast Vector3 to float”

Oh yes sorry for the mistake, you shouldn’t need a 1 so try removing that.

This is wrong; :ScaleTo() doesn’t take vectors.
If you want a random scale, you can use math.random(), the only issue is that math.random will round to the nearest whole number. You can get around this by doing something like this.

local ScaleFactor = math.random(800,1300)/1000
model:ScaleTo(ScaleFactor)

I see, ill be trying and fixing some stuff up and ill see what happens.

Very interesting solution; much appreciated, it didnt cross my mind to do
local ScaleFactor = math.random(800,1300)/1000

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.