Tool script isn't running properly

Hello!

I am having some issues with working on my tools within my new game update. The issue is, when the player uses the tool to get some Swing (leaderstat), it takes longer than usual to get more Swing after clicking.

The way it’s made is that the Player can get X amount of Swing by using the tool, then after the cooldown, which right now is 1, they can use the tool again to get more Swing. But, the tool is taking longer to get more Swing than what’s on the cooldown.

This issue hasn’t happened for just me, it’s also happened for my friend who has helped me to test the update. I don’t know if this is a lag issue, or just something else…

If anyone can help, much would be appreciated!

Thanks!

Can you show the tool script? (characters)

Sure, here is the tool.Activated script:

local _M = require(script.Parent.Settings)
local db = false 
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character 

local anim1 = tool:WaitForChild("LiftAnim")
local animtrack1 = character.Humanoid:LoadAnimation(anim1)

local anim2 = tool:WaitForChild("IdleAnim")
local animtrack2 = character.Humanoid:LoadAnimation(anim2)

tool.Activated:Connect(function()
	if not db then
		db = true
		animtrack1:Play()
		plr.leaderstats.Swing.Value = plr.leaderstats.Swing.Value + _M.strengthPerClick
		wait(_M.cooldown)
		db = false
	end
end)

tool.Equipped:Connect(function()
	character.Humanoid.WalkSpeed = 16
	animtrack2:Play()
end)

tool.Unequipped:Connect(function()
	character.Humanoid.WalkSpeed = 16
	animtrack2:Stop()
end)

Also I’ve been seeing these warning pop up only today:

Warning 1: CharacterManager: Equipped assets has not yet been initialized!

Does the line plr.leaderstats.Swing.Value = plr.leaderstats.Swing.Value + _M.strengthPerClick only run when the lift animation is done?

No, it runs once you’ve used the tool.

Did you try doing it without the Module script? Try plr.leaderstats.Swing.Value = plr.leaderstats.Swing.Value + 1

This script has always ran with the module script, it’s only today, and during the test of this update, that the issue had started. But I have never tried it without the module script.

Oh, perhaps try it? I think you are right not doing it without the module script because probably some things will change

I did the change, but it’s still the same result. It gave me the Swing, but the cooldown was still over the coded cooldown.