I am making a game where you have to click bombs before they explode and I can't make a timer that when it hits 30 the bomb will explode. THE PARTS WITH ASTRICTS ARE THE PARTS I NEED HELP WITH, BUT FEEL FREE TO LOOK AT THE REST IF THERE IS AN ISSUE :)
local clidet = script.Parent.ClickDetector -- finds the clickdetector
local prtdestroy = script.Parent -- finds the bomb
local prtmaxhealth = 500 -- bombs max health
local prthealth = prtmaxhealth -- sets the beginning health to the max
local prtdeath = 0 -- bombs health that it dies at
local weapondmg = 10
**local boomseconds = 30**
clidet.MouseClick:Connect(function() -- checks when the click detector is clicked
if prtdestroy.Parent == game.Workspace then -- checks if the parent of the bomb is workspace
wait(0.2) -- delay before next hit
prthealth = prthealth - weapondmg -- subtracts health
if prthealth == prtdeath then -- checks if the health of the bomb is the health that it dies at
prtdestroy:Destroy() -- destroys the part
end
end
end)
**for i = 1,boomseconds.Value do
wait(1)
boomseconds.Value = boomseconds.Value - 1
if boomseconds == 0 then
local explosion = Instance.new("Explosion")
explosion.Parent = prtdestroy
prtdestroy:Destroy()
end
end**

1 comment
maybe doing the line 22 local explosion = Instance.new("Explosion",workspace)