How resource intensive is using Random.new()?

Quick question; I’m scripting a cannon that can shoot canister, and when it hits the ground I plan on the sound of the canister hitting the ground’s playback speed be determined by Random.new() and Random:NextInteger(). My question is, how many “canisters” would I have to be creating to cause a noticeable amount of lag?
quick snippet of code incase you need it

local RNG = Random.new(tick()*10,000)
Impact.PlaybackSpeed = RNG:NextInteger(60, 100)/100
print(Impact.PlaybackSpeed)
Impact:Play()
wait(0.2)

PS. that’s being done thirty times (at different times, of course according to whenever the canister would hit the ground), since the cannon would fire 30 canisters at once

1 Like

I think you’d need to be creating tens of thousands to hundreds of thousands of new numbers in one non-yielding step to really notice any performance difference. I haven’t tested this, but it’s probably a good estimate since that’s about how fast the majority of the native APIs are.

2 Likes