KashTheKingYT

Spawn Powerups

Nov 7th, 2021
1,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. local powerups = game.ServerStorage.Powerups:GetChildren()
  2. local timer = 7
  3. local y = 3.5
  4.  
  5. function spawnPowerup(number)
  6.     local powerup = powerups[number]
  7.     local rangeX = math.random(-60, 36)
  8.     local rangeZ = math.random(-137.5, -41.5)
  9.     local spawnedPowerup = powerup:Clone()
  10.     spawnedPowerup.Parent = game.Workspace
  11.     spawnedPowerup.Position = Vector3.new(rangeX, y, rangeZ)
  12. end
  13.  
  14. while true do
  15.     local number = math.random(1,#powerups)
  16.     spawnPowerup(number)
  17.     wait(timer)
  18. end
Advertisement
Add Comment
Please, Sign In to add comment