01 | while true do |
02 | local cloned = game.ServerStorage.Boulder:Clone() |
03 | local spawn = math.random( 1 , 3 ) |
04 | if spawn = = 1 then |
05 | cloned.CFrame = CFrame.new(- 1467.45 , 459.622 , 37.152 ) |
06 | end |
07 | if spawn = = 2 then |
08 | cloned.CFrame = CFrame.new(- 1467.45 , 459.622 , 21.152 ) |
09 | end |
10 | if spawn = = 3 then |
11 | cloned.CFrame = CFrame.new(- 1467.45 , 459.622 , 12.152 ) |
12 | end |
13 | wait( 2 ) |
14 | end |
im trying to spawn a boulder randomly but idk why it is not working
When cloning an instance, it's not parented on its own, you'd have to write a separate line for it.
01 | while wait( 2 ) do --Every 2 seconds, the loop executes |
02 | local cloned = game.ServerStorage.Boulder:Clone() |
03 | cloned.Parent = game.Workspace |
04 | local spawn = math.random( 3 ) --Generates a number between 1 and 3, math.random(1, 3) only chooses between 1 and 3 |
05 | if spawn = = 1 then |
06 | cloned.CFrame = CFrame.new(- 1467.45 , 459.622 , 37.152 ) |
07 | elseif spawn = = 2 then |
08 | cloned.CFrame = CFrame.new(- 1467.45 , 459.622 , 21.152 ) |
09 | elseif spawn = = 3 then |
10 | cloned.CFrame = CFrame.new(- 1467.45 , 459.622 , 12.152 ) |
11 | end |
12 | end |