Tool cooldown issue

Hello!
I am new to scripting and I was wondering how to add cooldown to this tool:

I wanted to put in my game a pass that gives you a nuke tool, but this tool doesn’t have a reloading time and spawns bomb nukes with no cooldown

How do I put a cooldown to this tool?

The model is called “Fat Man Bomb”, but if you don’t want to search it I will show you here what are the scripts:

Screenshot (15)

–SCRIPTS:–

“Atom” Script: ------------------------------------------------------------------------------------------

print(“Nuke Em’ All”)
script.Parent.Anchored = true

local CloudID= “http://www.roblox.com/asset/?id=1095708
local ColorTexture = “http://www.roblox.com/asset/?ID=1361097
local RingID = “http://www.roblox.com/asset/?id=3270017
local SphereID = “http://www.roblox.com/asset/?id=1185246

local BasePosition = script.Parent.Position

local Size = 30

local Exp = Instance.new(“Model”)
Exp.Name = “ATOMICEXPLOSION”
Exp.Parent = game.Workspace

local BasePart = Instance.new(“Part”)
BasePart.formFactor = 0
BasePart.TopSurface = 0
BasePart.BottomSurface = 0
BasePart.Anchored = true
BasePart.Locked = true
BasePart.CanCollide = false

local BaseMesh = Instance.new(“SpecialMesh”)
BaseMesh.MeshType = “FileMesh”

local CloudMesh = BaseMesh:clone()
CloudMesh.MeshId = CloudID
CloudMesh.TextureId = ColorTexture
CloudMesh.VertexColor = Vector3.new(0.9,0.6,0)

local RingMesh = BaseMesh:clone()
RingMesh.MeshId = RingID

local SphereMesh = BaseMesh:clone()
SphereMesh.MeshId = SphereID

local Clouds = {}
local ShockWave = {}

function Effects()
script.Explode2:Play()
script.Explode:Play()
delay(0,function()
for i = 5, 1,-0.01 do
wait()
end
end)
end

function Destruction(Pos,Radius)
local function Destroy(Model)
for i ,v in ipairs(Model:getChildren()) do
if v:isA(“BasePart”) then
if (v.Position-Pos).magnitude < Radius then
if v.Anchored == false then
v:BreakJoints()
v.Velocity = CFrame.new(v.Position,Pos):vectorToWorldSpace(Vector3.new(math.random(-5,5),5,1000))
v.Material = “CorrodedMetal”
end
end
end
if #v:getChildren() > 0 then
Destroy(v)
end
end
end
Destroy(game.Workspace)
end
function Explode(Pos)

local Base = BasePart:clone()
Base.Position = Pos

local Mesh = CloudMesh:clone()
Mesh.Parent = Base
Mesh.Scale = Vector3.new(2.5,1,4.5)

local PoleBase = BasePart:clone()
PoleBase.Position = Pos+Vector3.new(0,0.1,0)

local PoleBaseMesh = CloudMesh:clone()
PoleBaseMesh.Scale = Vector3.new(1.25,2,2.5)
PoleBaseMesh.Parent = PoleBase

local Cloud1 = BasePart:clone()
Cloud1.Position = Pos+Vector3.new(0,0.75,0)

local Cloud1Mesh = CloudMesh:clone()
Cloud1Mesh.Scale = Vector3.new(0.5,3,1)
Cloud1Mesh.Parent = Cloud1

local Cloud2 = BasePart:clone()
Cloud2.Position = Pos+Vector3.new(0,1.25,0)

local Cloud2Mesh = CloudMesh:clone()
Cloud2Mesh.Scale = Vector3.new(0.5,1.5,1)
Cloud2Mesh.Parent = Cloud2

local Cloud3 = BasePart:clone()
Cloud3.Position = Pos+Vector3.new(0,1.7,0)

local Cloud3Mesh = CloudMesh:clone()
Cloud3Mesh.Scale = Vector3.new(0.5,1.5,1)
Cloud3Mesh.Parent = Cloud3

local PoleRing = BasePart:clone()
PoleRing.Position = Pos+Vector3.new(0,1.3,0)
PoleRing.Transparency = 0.2
PoleRing.BrickColor = BrickColor.new(“Dark stone grey”)
PoleRing.CFrame = PoleRing.CFrame*CFrame.Angles(math.rad(90),0,0)

local Mesh = RingMesh:clone()
Mesh.Scale = Vector3.new(1.2,1.2,1.2)
Mesh.Parent = PoleRing

local MushCloud = BasePart:clone()
MushCloud.Position = Pos+Vector3.new(0,2.3,0)

local MushMesh = CloudMesh:clone() – lol
MushMesh.Scale = Vector3.new(2.5,1.75,3.5)
MushMesh.Parent = MushCloud

local TopCloud = BasePart:clone()
TopCloud.Position = Pos+Vector3.new(0,2.7,0)

local TopMesh = CloudMesh:clone()
TopMesh.Scale = Vector3.new(7.5,1.5,1.5)
TopMesh.Parent = TopCloud

table.insert(Clouds,Base)
table.insert(Clouds,TopCloud)
table.insert(Clouds,MushCloud)
table.insert(Clouds,Cloud1)
table.insert(Clouds,Cloud2)
table.insert(Clouds,Cloud3)
table.insert(Clouds,PoleBase)
table.insert(Clouds,PoleRing)

local BigRing = BasePart:clone()
BigRing.Position = Pos
BigRing.CFrame = BigRing.CFrame*CFrame.Angles(math.rad(90),0,0)

local BigMesh = RingMesh:clone()
BigMesh.Scale = Vector3.new(5,5,1)
BigMesh.Parent = BigRing

local SmallRing = BasePart:clone()
SmallRing.Position = Pos
SmallRing.BrickColor = BrickColor.new(“Dark stone grey”)
SmallRing.CFrame = SmallRing.CFrame*CFrame.Angles(math.rad(90),0,0)

local SmallMesh = RingMesh:clone()
SmallMesh.Scale = Vector3.new(4.6,4.6,1.5)
SmallMesh.Parent = SmallRing

local InnerSphere = BasePart:clone()
InnerSphere.Position = Pos
InnerSphere.BrickColor = BrickColor.new(“Bright orange”)
InnerSphere.Transparency = 0.5

local InnerSphereMesh = SphereMesh:clone()
InnerSphereMesh.Scale = Vector3.new(-6.5,-6.5,-6.5)
InnerSphereMesh.Parent = InnerSphere

local OutterSphere = BasePart:clone()
OutterSphere.Position = Pos
OutterSphere.BrickColor = BrickColor.new(“Bright orange”)
OutterSphere.Transparency = 0.5

local OutterSphereMesh = SphereMesh:clone()
OutterSphereMesh.Scale = Vector3.new(6.5,6.5,6.5)
OutterSphereMesh.Parent = OutterSphere

table.insert(ShockWave,BigRing)
table.insert(ShockWave,SmallRing)
table.insert(ShockWave,OutterSphere)
table.insert(ShockWave,InnerSphere)

for i , v in ipairs(ShockWave) do
	v.Parent = Exp
end
for i , v in ipairs(Clouds) do
	v.Parent = Exp
end
Effects()
delay(0,function()
	for resize = Size/2.5, Size*3, 2 do
		wait()
		BigRing.Mesh.Scale = Vector3.new(5*resize,5*resize,1*resize)
		SmallRing.Mesh.Scale = Vector3.new(4.6*resize,4.6*resize,1.5*resize)
		InnerSphere.Mesh.Scale = Vector3.new(-6.5*resize,-6.5*resize,-6.5*resize)
		OutterSphere.Mesh.Scale = Vector3.new(6.5*resize,6.5*resize,6.5*resize)
		Destruction(Pos,3*resize)
	end
	for fade = 0, 1, 0.01 do
		wait()
		pcall(function()
			for i ,v in ipairs(ShockWave) do
				v.Transparency = fade
			end
		end)
	end
	for i ,v in ipairs(ShockWave) do
		v:Remove()
	end
	done1 = true
end)
delay(0,function()
	for resize = Size/5, Size, 1 do
		wait()
		pcall(function()
			Base.Mesh.Scale = Vector3.new(2.5*resize,1*resize,4.5*resize)
			TopCloud.Mesh.Scale = Vector3.new(0.75*resize,1.5*resize,1.5*resize)
			MushCloud.Mesh.Scale = Vector3.new(2.5*resize,1.75*resize,3.5*resize)
			Cloud1.Mesh.Scale = Vector3.new(0.5*resize,3*resize,1*resize)
			Cloud2.Mesh.Scale = Vector3.new(0.5*resize,1.5*resize,1*resize)
			Cloud3.Mesh.Scale = Vector3.new(0.5*resize,1.5*resize,1*resize)
			PoleBase.Mesh.Scale = Vector3.new(1*resize,2*resize,2.5*resize)
			PoleRing.Mesh.Scale = Vector3.new(1.2*resize,1.2*resize,1.2*resize)

			Base.Position = Pos+Vector3.new(0,0.05*resize,0)
			TopCloud.Position = Pos+Vector3.new(0,2.7*resize,0)
			MushCloud.Position = Pos+Vector3.new(0,2.3*resize,0)
			Cloud1.Position = Pos+Vector3.new(0,0.75*resize,0)
			Cloud2.Position = Pos+Vector3.new(0,1.25*resize,0)
			Cloud3.Position = Pos+Vector3.new(0,1.7*resize,0)
			PoleBase.Position = Pos+Vector3.new(0,0.1*resize,0)
			PoleRing.Position = Pos+Vector3.new(0,1.3*resize,0)
		end)
	end
	done2 = true
end)
wait(2)
for y = 0.6,0,-0.0025 do
	wait()
	for i , v in ipairs(Clouds) do
		v.Mesh.VertexColor = Vector3.new(0.9,y,0)
	end
end
for r = 0.9,0.5,-0.01 do
	wait()
	for i , v in ipairs(Clouds) do
		v.Mesh.VertexColor = Vector3.new(r,0,0)
	end
end
for by = 0,0.5,0.005 do
	wait()
	for i , v in ipairs(Clouds) do
		v.Mesh.VertexColor = Vector3.new(0.5,by,by)
		v.Transparency = by*2
	end
	Base.Mesh.Scale = Base.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	TopCloud.Mesh.Scale = TopCloud.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	MushCloud.Mesh.Scale = MushCloud.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	Cloud1.Mesh.Scale = Cloud1.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	Cloud2.Mesh.Scale = Cloud2.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	Cloud3.Mesh.Scale = Cloud3.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	PoleBase.Mesh.Scale = PoleBase.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	PoleRing.Mesh.Scale = PoleRing.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
end
done3 = true
while true do wait(1) if done1 and done2 and done3 then break end end
Exp:remove()
wait(20)

end

Explode(BasePosition)

script.Parent:remove()

“Bomb” script:----------------------------------------------------------------------------------------------

local updateInterval = .4

local currentColor = 1
local colors = {26, 21}

local ticksound = Instance.new(“Sound”)
ticksound.SoundId = “rbxasset://sounds\clickfast.wav”
ticksound.Parent = script.Parent

function update()
updateInterval = updateInterval * .9
script.Parent.BrickColor = BrickColor.new(colors[currentColor])
currentColor = currentColor + 1
if (currentColor > 2) then currentColor = 1 end
end

function blowUp()
local sound = Instance.new(“Sound”)
sound.SoundId = “rbxasset://sounds\Rocket shot.wav”
sound.Parent = script.Parent
sound.Volume = 10
sound:play()
–find instigator tag
local creator = script.Parent:findFirstChild(“creator”)
if creator ~= nil then
end
end

function onPlayerBlownUp(part, distance, creator)
if part.Name == “Head” then
local humanoid = part.Parent.Humanoid
tagHumanoid(humanoid, creator)
end
end

function tagHumanoid(humanoid, creator)
– tag does not need to expire iff all explosions lethal
if creator ~= nil then
local new_tag = creator:clone()
new_tag.Parent = humanoid
end
end

function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild(“creator”)
if tag ~= nil then
tag.Parent = nil
end
end
end

while updateInterval > .05 do
wait(updateInterval)
update()
ticksound:play()
end

blowUp()
script.Parent.Transparency = 1

“Plant bomb” script:-------------------------------------------------------------------------------------

local bombScript = script.Parent.Bomb
local Tool = script.Parent
local Bomb = Tool.Handle

function plant()
local bomb2 = Instance.new(“Part”)

local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local spawnPos = Bomb.Position

bomb2.Position = Vector3.new(spawnPos.x, spawnPos.y+3, spawnPos.z)
bomb2.Size = Vector3.new(4,4,4)

bomb2.BrickColor = BrickColor.new(21)
bomb2.Shape = 0
bomb2.BottomSurface = 0
bomb2.TopSurface = 0
bomb2.Reflectance = 1
bomb2.Name = "TimeBomb"
bomb2.Locked = true

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = bomb2

bomb2.Parent = game.Workspace
local new_script = bombScript:clone()
new_script.Disabled = false
new_script.Parent = bomb2
local i = script.Parent.BombScripts.Atom
delay(5, function()
	local lol = i:Clone()
	lol.Parent = bomb2
	wait(0.2)
	lol.Disabled = false
end)

end

Tool.Enabled = true
function onActivated()

if not Tool.Enabled then
	return
end

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
	print("Humanoid not found")
	return 
end

local targetPos = humanoid.TargetPoint

plant()

end

function onUnequipped()
end

Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)


So in wich script do I add the cooldown script? How do I do it?
Can someone that knows about scripting help me? I would really appreciate it!

Thanks for reading!

ds: Cosmo#7183

1 Like

Sorry, but the code is not formatted, making us hard to read and help you. Can you please first format your code?

1 Like
print(“Nuke Em’ All”)
script.Parent.Anchored = true

local CloudID= “http://www.roblox.com/asset/?id=1095708”
local ColorTexture = “http://www.roblox.com/asset/?ID=1361097”
local RingID = “http://www.roblox.com/asset/?id=3270017”
local SphereID = “http://www.roblox.com/asset/?id=1185246”

local BasePosition = script.Parent.Position

local Size = 30

local Exp = Instance.new(“Model”)
Exp.Name = “ATOMICEXPLOSION”
Exp.Parent = game.Workspace

local BasePart = Instance.new(“Part”)
BasePart.formFactor = 0
BasePart.TopSurface = 0
BasePart.BottomSurface = 0
BasePart.Anchored = true
BasePart.Locked = true
BasePart.CanCollide = false

local BaseMesh = Instance.new(“SpecialMesh”)
BaseMesh.MeshType = “FileMesh”

local CloudMesh = BaseMesh:clone()
CloudMesh.MeshId = CloudID
CloudMesh.TextureId = ColorTexture
CloudMesh.VertexColor = Vector3.new(0.9,0.6,0)

local RingMesh = BaseMesh:clone()
RingMesh.MeshId = RingID

local SphereMesh = BaseMesh:clone()
SphereMesh.MeshId = SphereID

local Clouds = {}
local ShockWave = {}

function Effects()
script.Explode2:Play()
script.Explode:Play()
delay(0,function()
for i = 5, 1,-0.01 do
wait()
end
end)
end

function Destruction(Pos,Radius)
local function Destroy(Model)
for i ,v in ipairs(Model:getChildren()) do
if v:isA(“BasePart”) then
if (v.Position-Pos).magnitude < Radius then
if v.Anchored == false then
v:BreakJoints()
v.Velocity = CFrame.new(v.Position,Pos):vectorToWorldSpace(Vector3.new(math.random(-5,5),5,1000))
v.Material = “CorrodedMetal”
end
end
end
if #v:getChildren() > 0 then
Destroy(v)
end
end
end
Destroy(game.Workspace)
end
function Explode(Pos)

local Base = BasePart:clone()
Base.Position = Pos

local Mesh = CloudMesh:clone()
Mesh.Parent = Base
Mesh.Scale = Vector3.new(2.5,1,4.5)

local PoleBase = BasePart:clone()
PoleBase.Position = Pos+Vector3.new(0,0.1,0)

local PoleBaseMesh = CloudMesh:clone()
PoleBaseMesh.Scale = Vector3.new(1.25,2,2.5)
PoleBaseMesh.Parent = PoleBase

local Cloud1 = BasePart:clone()
Cloud1.Position = Pos+Vector3.new(0,0.75,0)

local Cloud1Mesh = CloudMesh:clone()
Cloud1Mesh.Scale = Vector3.new(0.5,3,1)
Cloud1Mesh.Parent = Cloud1

local Cloud2 = BasePart:clone()
Cloud2.Position = Pos+Vector3.new(0,1.25,0)

local Cloud2Mesh = CloudMesh:clone()
Cloud2Mesh.Scale = Vector3.new(0.5,1.5,1)
Cloud2Mesh.Parent = Cloud2

local Cloud3 = BasePart:clone()
Cloud3.Position = Pos+Vector3.new(0,1.7,0)

local Cloud3Mesh = CloudMesh:clone()
Cloud3Mesh.Scale = Vector3.new(0.5,1.5,1)
Cloud3Mesh.Parent = Cloud3

local PoleRing = BasePart:clone()
PoleRing.Position = Pos+Vector3.new(0,1.3,0)
PoleRing.Transparency = 0.2
PoleRing.BrickColor = BrickColor.new(“Dark stone grey”)
PoleRing.CFrame = PoleRing.CFrame*CFrame.Angles(math.rad(90),0,0)

local Mesh = RingMesh:clone()
Mesh.Scale = Vector3.new(1.2,1.2,1.2)
Mesh.Parent = PoleRing

local MushCloud = BasePart:clone()
MushCloud.Position = Pos+Vector3.new(0,2.3,0)

local MushMesh = CloudMesh:clone() – lol
MushMesh.Scale = Vector3.new(2.5,1.75,3.5)
MushMesh.Parent = MushCloud

local TopCloud = BasePart:clone()
TopCloud.Position = Pos+Vector3.new(0,2.7,0)

local TopMesh = CloudMesh:clone()
TopMesh.Scale = Vector3.new(7.5,1.5,1.5)
TopMesh.Parent = TopCloud

table.insert(Clouds,Base)
table.insert(Clouds,TopCloud)
table.insert(Clouds,MushCloud)
table.insert(Clouds,Cloud1)
table.insert(Clouds,Cloud2)
table.insert(Clouds,Cloud3)
table.insert(Clouds,PoleBase)
table.insert(Clouds,PoleRing)

local BigRing = BasePart:clone()
BigRing.Position = Pos
BigRing.CFrame = BigRing.CFrame*CFrame.Angles(math.rad(90),0,0)

local BigMesh = RingMesh:clone()
BigMesh.Scale = Vector3.new(5,5,1)
BigMesh.Parent = BigRing

local SmallRing = BasePart:clone()
SmallRing.Position = Pos
SmallRing.BrickColor = BrickColor.new(“Dark stone grey”)
SmallRing.CFrame = SmallRing.CFrame*CFrame.Angles(math.rad(90),0,0)

local SmallMesh = RingMesh:clone()
SmallMesh.Scale = Vector3.new(4.6,4.6,1.5)
SmallMesh.Parent = SmallRing

local InnerSphere = BasePart:clone()
InnerSphere.Position = Pos
InnerSphere.BrickColor = BrickColor.new(“Bright orange”)
InnerSphere.Transparency = 0.5

local InnerSphereMesh = SphereMesh:clone()
InnerSphereMesh.Scale = Vector3.new(-6.5,-6.5,-6.5)
InnerSphereMesh.Parent = InnerSphere

local OutterSphere = BasePart:clone()
OutterSphere.Position = Pos
OutterSphere.BrickColor = BrickColor.new(“Bright orange”)
OutterSphere.Transparency = 0.5

local OutterSphereMesh = SphereMesh:clone()
OutterSphereMesh.Scale = Vector3.new(6.5,6.5,6.5)
OutterSphereMesh.Parent = OutterSphere

table.insert(ShockWave,BigRing)
table.insert(ShockWave,SmallRing)
table.insert(ShockWave,OutterSphere)
table.insert(ShockWave,InnerSphere)

for i , v in ipairs(ShockWave) do
	v.Parent = Exp
end
for i , v in ipairs(Clouds) do
	v.Parent = Exp
end
Effects()
delay(0,function()
	for resize = Size/2.5, Size*3, 2 do
		wait()
		BigRing.Mesh.Scale = Vector3.new(5*resize,5*resize,1*resize)
		SmallRing.Mesh.Scale = Vector3.new(4.6*resize,4.6*resize,1.5*resize)
		InnerSphere.Mesh.Scale = Vector3.new(-6.5*resize,-6.5*resize,-6.5*resize)
		OutterSphere.Mesh.Scale = Vector3.new(6.5*resize,6.5*resize,6.5*resize)
		Destruction(Pos,3*resize)
	end
	for fade = 0, 1, 0.01 do
		wait()
		pcall(function()
			for i ,v in ipairs(ShockWave) do
				v.Transparency = fade
			end
		end)
	end
	for i ,v in ipairs(ShockWave) do
		v:Remove()
	end
	done1 = true
end)
delay(0,function()
	for resize = Size/5, Size, 1 do
		wait()
		pcall(function()
			Base.Mesh.Scale = Vector3.new(2.5*resize,1*resize,4.5*resize)
			TopCloud.Mesh.Scale = Vector3.new(0.75*resize,1.5*resize,1.5*resize)
			MushCloud.Mesh.Scale = Vector3.new(2.5*resize,1.75*resize,3.5*resize)
			Cloud1.Mesh.Scale = Vector3.new(0.5*resize,3*resize,1*resize)
			Cloud2.Mesh.Scale = Vector3.new(0.5*resize,1.5*resize,1*resize)
			Cloud3.Mesh.Scale = Vector3.new(0.5*resize,1.5*resize,1*resize)
			PoleBase.Mesh.Scale = Vector3.new(1*resize,2*resize,2.5*resize)
			PoleRing.Mesh.Scale = Vector3.new(1.2*resize,1.2*resize,1.2*resize)

			Base.Position = Pos+Vector3.new(0,0.05*resize,0)
			TopCloud.Position = Pos+Vector3.new(0,2.7*resize,0)
			MushCloud.Position = Pos+Vector3.new(0,2.3*resize,0)
			Cloud1.Position = Pos+Vector3.new(0,0.75*resize,0)
			Cloud2.Position = Pos+Vector3.new(0,1.25*resize,0)
			Cloud3.Position = Pos+Vector3.new(0,1.7*resize,0)
			PoleBase.Position = Pos+Vector3.new(0,0.1*resize,0)
			PoleRing.Position = Pos+Vector3.new(0,1.3*resize,0)
		end)
	end
	done2 = true
end)
wait(2)
for y = 0.6,0,-0.0025 do
	wait()
	for i , v in ipairs(Clouds) do
		v.Mesh.VertexColor = Vector3.new(0.9,y,0)
	end
end
for r = 0.9,0.5,-0.01 do
	wait()
	for i , v in ipairs(Clouds) do
		v.Mesh.VertexColor = Vector3.new(r,0,0)
	end
end
for by = 0,0.5,0.005 do
	wait()
	for i , v in ipairs(Clouds) do
		v.Mesh.VertexColor = Vector3.new(0.5,by,by)
		v.Transparency = by*2
	end
	Base.Mesh.Scale = Base.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	TopCloud.Mesh.Scale = TopCloud.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	MushCloud.Mesh.Scale = MushCloud.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	Cloud1.Mesh.Scale = Cloud1.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	Cloud2.Mesh.Scale = Cloud2.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	Cloud3.Mesh.Scale = Cloud3.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	PoleBase.Mesh.Scale = PoleBase.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
	PoleRing.Mesh.Scale = PoleRing.Mesh.Scale+Vector3.new(0.1,0.1,0.1)
end
done3 = true
while true do wait(1) if done1 and done2 and done3 then break end end
Exp:remove()
wait(20)

end

Explode(BasePosition)

script.Parent:remove()

“Bomb” script:----------------------------------------------------------------------------------------------

local updateInterval = .4

local currentColor = 1
local colors = {26, 21}

local ticksound = Instance.new(“Sound”)
ticksound.SoundId = “rbxasset://sounds\clickfast.wav”
ticksound.Parent = script.Parent

function update()
updateInterval = updateInterval * .9
script.Parent.BrickColor = BrickColor.new(colors[currentColor])
currentColor = currentColor + 1
if (currentColor > 2) then currentColor = 1 end
end

function blowUp()
local sound = Instance.new(“Sound”)
sound.SoundId = “rbxasset://sounds\Rocket shot.wav”
sound.Parent = script.Parent
sound.Volume = 10
sound:play()
–find instigator tag
local creator = script.Parent:findFirstChild(“creator”)
if creator ~= nil then
end
end

function onPlayerBlownUp(part, distance, creator)
if part.Name == “Head” then
local humanoid = part.Parent.Humanoid
tagHumanoid(humanoid, creator)
end
end

function tagHumanoid(humanoid, creator)
– tag does not need to expire iff all explosions lethal
if creator ~= nil then
local new_tag = creator:clone()
new_tag.Parent = humanoid
end
end

function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild(“creator”)
if tag ~= nil then
tag.Parent = nil
end
end
end

while updateInterval > .05 do
wait(updateInterval)
update()
ticksound:play()
end

blowUp()
script.Parent.Transparency = 1

“Plant bomb” script:-------------------------------------------------------------------------------------

local bombScript = script.Parent.Bomb
local Tool = script.Parent
local Bomb = Tool.Handle

function plant()
local bomb2 = Instance.new(“Part”)

local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local spawnPos = Bomb.Position

bomb2.Position = Vector3.new(spawnPos.x, spawnPos.y+3, spawnPos.z)
bomb2.Size = Vector3.new(4,4,4)

bomb2.BrickColor = BrickColor.new(21)
bomb2.Shape = 0
bomb2.BottomSurface = 0
bomb2.TopSurface = 0
bomb2.Reflectance = 1
bomb2.Name = "TimeBomb"
bomb2.Locked = true

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = bomb2

bomb2.Parent = game.Workspace
local new_script = bombScript:clone()
new_script.Disabled = false
new_script.Parent = bomb2
local i = script.Parent.BombScripts.Atom
delay(5, function()
	local lol = i:Clone()
	lol.Parent = bomb2
	wait(0.2)
	lol.Disabled = false
end)

end

Tool.Enabled = true
function onActivated()

if not Tool.Enabled then
	return
end

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
	print("Humanoid not found")
	return 
end

local targetPos = humanoid.TargetPoint

plant()

end

function onUnequipped()
end

Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)

Can you please separate parts of the script into its respective script? I dont want all of the scripts which are involved are included in one script.

I mean you could look through it. But here

local bombScript = script.Parent.Bomb
local Tool = script.Parent
local Bomb = Tool.Handle

function plant()
local bomb2 = Instance.new(“Part”)

local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local spawnPos = Bomb.Position

bomb2.Position = Vector3.new(spawnPos.x, spawnPos.y+3, spawnPos.z)
bomb2.Size = Vector3.new(4,4,4)

bomb2.BrickColor = BrickColor.new(21)
bomb2.Shape = 0
bomb2.BottomSurface = 0
bomb2.TopSurface = 0
bomb2.Reflectance = 1
bomb2.Name = "TimeBomb"
bomb2.Locked = true

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = bomb2

bomb2.Parent = game.Workspace
local new_script = bombScript:clone()
new_script.Disabled = false
new_script.Parent = bomb2
local i = script.Parent.BombScripts.Atom
delay(5, function()
	local lol = i:Clone()
	lol.Parent = bomb2
	wait(0.2)
	lol.Disabled = false
end)

end

Tool.Enabled = true
function onActivated()

if not Tool.Enabled then
	return
end

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
	print("Humanoid not found")
	return 
end

local targetPos = humanoid.TargetPoint

plant()

end

function onUnequipped()
end

Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)

Here, try replacing the plant bomb script with this. I added comments so you could understand what I did.

local bombScript = script.Parent.Bomb
local Tool = script.Parent
local Bomb = Tool.Handle
local cooldown = false
local cooldown_Time = 45 -- Change this number to change the cooldown time. Time format is seconds

function plant()
	if cooldown == false then -- Check if cooldown is active, if so, dont plant the bomb
		cooldown = true -- set cooldown to true, so we cant plant a bomb
		local bomb2 = Instance.new("Part")

		local vCharacter = Tool.Parent
		local vPlayer = game.Players:playerFromCharacter(vCharacter)

		local spawnPos = Bomb.Position

		bomb2.Position = Vector3.new(spawnPos.x, spawnPos.y+3, spawnPos.z)
		bomb2.Size = Vector3.new(4,4,4)

		bomb2.BrickColor = BrickColor.new(21)
		bomb2.Shape = 0
		bomb2.BottomSurface = 0
		bomb2.TopSurface = 0
		bomb2.Reflectance = 1
		bomb2.Name = "TimeBomb"
		bomb2.Locked = true

		local creator_tag = Instance.new("ObjectValue")
		creator_tag.Value = vPlayer
		creator_tag.Name = "creator"
		creator_tag.Parent = bomb2

		bomb2.Parent = game.Workspace
		local new_script = bombScript:clone()
		new_script.Disabled = false
		new_script.Parent = bomb2
		local i = script.Parent.BombScripts.Atom
		delay(5, function()
			local lol = i:Clone()
			lol.Parent = bomb2
			wait(0.2)
			lol.Disabled = false
		end)
		wait(cooldown_Time) -- wait the cooldown length
		cooldown = false -- set the cooldown to false after the time limit so we can plant bombs again
	else
		print("Cooldown") -- print cooldown when on cooldown
	end
end

Tool.Enabled = true
function onActivated()

	if not Tool.Enabled then
		return
	end

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return 
	end

	local targetPos = humanoid.TargetPoint

	plant()

end

function onUnequipped()
end

Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)
1 Like

It works! Thank you so much! : )

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.