Bomb with Timer

Script for Bomb

local bomb = script.Parent

local timer = bomb.BillboardGui.Timer

local timeAmount = 15

local blastRange = 15


timer.Text = timeAmount


while timeAmount > 0 do

wait(1)

timeAmount -= 1

timer.Text = timeAmount

end


local explosion = Instance.new('Explosion')

explosion.Parent = game.Workspace

explosion.Position = bomb.Position

explosion.BlastRadius = blastRange

bomb.Parent:Destroy()

Script for Trigger

local trigger = script.Parent

local storage = game:GetService('ServerStorage')

local canActivate = true

local spawnRange = 50


local function make_bomb(otherPart)

local humanoid = otherPart.Parent:FindFirstChild('Humanoid')

if humanoid and canActivate then

canActivate = false

local bomb = storage:FindFirstChild('Bomb'):Clone()

local x = math.random(trigger.Position.X - spawnRange, trigger.Position.X + spawnRange)

local z = math.random(trigger.Position.Z - spawnRange, trigger.Position.Z + spawnRange)

bomb.Parent = game.Workspace

bomb.Main.Position = Vector3.new(x,3,z)

wait(3)

canActivate = true

end

end


trigger.Touched:Connect(make_bomb)