I wanted to add a cool down onto my bomb, now it isnt working

That’s exactly what I thought, but assuming all he added was the debounce, it was working before that and didn’t have a cool down, if he added those along with the debounce, that could be the error

1 Like

No problem, make sure to mark as solution so people don’t think it’s still unsolved unless it isn’t
Have a good day

its working now but i can only use the bomb once until i reset or die

bombScript = script.Parent.Bomb
Tool = script.Parent
local debounce = 0
Tool.Enabled = true
cooldown = 10

function onActivated()
	if debounce == 0 then
		debounce = 1
		local character = Tool.Parent
		local humanoid = character.Humanoid
		if humanoid == nil then
			print("Humanoid not found")
			return
		end

		local targetPos = humanoid.TargetPoint

		Tool.Handle.Transparency = 1
		plant(Tool.Handle.Position)
		wait()
		Tool.Handle.Transparency = 0
	end
end

function plant(pos)
	if debounce == 1 then

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

		local spawnPos = vCharacter.PrimaryPart.Position

		local bomb = Tool.Handle:Clone()
		bomb.CanCollide = true
		bomb.Transparency = 0
		bomb.Position = pos
		bomb.Size = Vector3.new(2, 2, 2)
		bomb.Name = "FuseBomb"
		bomb.Locked = true

		local spark = Instance.new("Sparkles")
		spark.Name = "Fuse"
		spark.Parent = bomb

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

		bomb.Parent = game.Workspace
		local new_script = bombScript:clone()
		new_script.Disabled = false
		new_script.Parent = bomb
		Tool.Enabled = true
		wait(cooldown)
		debounce = 0
	end
end
script.Parent.Activated:connect(onActivated)

Try this, I just reformatted your script so it’s a bit more readable, since onActivated is firing first and then plant is firing, it’s better to have that one above it for readability since this is such a small script, also you don’t need Tool.Enable / Tool.Disable if you already have a debounce in place, try this, if it doesn’t work, show a screenshot of everything in the console even if there’s nothing in there, I’d just like to see

I also added a cooldown value so you can manually change how long you want it to be for testing/etc. at the top

1 Like

'The funcitions must be in the original order, because “plant” must be defined, before it is called, I believe.

OP,
no idea. Sprinkel Prints all over and make sure that your debounces are being reset…

1 Like

dude youre a life saver thanks

1 Like

thank u too for ur help both of u helped so much

Exactly what I was thinking lol.

No probs…

I DO need an all-around Builder, animator, artist, with a good eye, for an RTS on a globe…