How do I make this function stop after 20 seconds?
I tried making it so that when a person touches this part it rains bombs from the sky for 20 seconds and stops after. Since nothing was working, I even tried making a separate brick to stop the function, but I do not know if that works at all..
how will I make the raining stop after 20 seconds?? :(
here is my code
01 | local bomb = game.ReplicatedStorage.Bomb:clone() |
02 | game.ReplicatedStorage.Bomb.Anchored = false |
03 | local player = game.Players.LocalPlayer |
04 | local bridge = game.Workspace.Bridge |
05 | local bombactivator = game.Workspace.BOMBING |
07 | local function skybombing() |
09 | local bombClone = bomb:clone() |
10 | bombClone.Position = Vector 3. new(math.random(- 500 , 500 ), 500 ,math.random(- 500 , 500 )) |
11 | bombClone.Parent = game.Workspace |
12 | bombClone.Anchored = false |
14 | if wait( 20 ) then break |
20 | bombactivator.Touched:Connect( function (Touched) |
21 | if Touched.Parent:FindFirstChild( "Humanoid" ) then |
23 | bombactivator.BrickColor = BrickColor.Red() |