My tool is only firing after I added the cooldown, I tried changing the cooldown position but didn’t work, help pls
local Equipped = false
local CombaTOOL = script.Parent
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local Char = Player.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local Combo = 1
local CD = false
CombaTOOL.Equipped:Connect(function()
Equipped = true
end)
CombaTOOL.Unequipped:Connect(function()
Equipped = false
end)
UIS.InputBegan:Connect(function(Input, GameProcessed)
if Equipped then
if Input.UserInputType == Enum.UserInputType.MouseButton1 and CD == false then
CD = true
RS.CRemote:FireServer()
print("!!!")
if Combo == 1 then
local RightPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.RightPunch)
RightPunch:Play()
Combo = 2
elseif Combo == 2 then
local LeftPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.LeftPunch)
LeftPunch:Play()
Combo = 1
wait(0.5)
CD = false
end
end
end
end)
You put the CD = false inside the elseif Combo == 2. Since you set the Combo value to 1, it wont change the cooldown to false.
Move it outside instead.
elseif Combo == 2 then
local LeftPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.LeftPunch)
LeftPunch:Play()
Combo = 1
end
wait(0.5)
CD = false
The CD is only being set to false in Combo 2. Set it to false in combo 1 and it should fix the issue.
local Equipped = false
local CombaTOOL = script.Parent
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local Char = Player.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local Combo = 1
local CD = false
CombaTOOL.Equipped:Connect(function()
Equipped = true
end)
CombaTOOL.Unequipped:Connect(function()
Equipped = false
end)
UIS.InputBegan:Connect(function(Input, GameProcessed)
if Equipped then
if Input.UserInputType == Enum.UserInputType.MouseButton1 and CD == false then
CD = true
RS.CRemote:FireServer()
print("!!!")
if Combo == 1 then
local RightPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.RightPunch)
RightPunch:Play()
Combo = 2
wait(0.5)
CD = false
elseif Combo == 2 then
local LeftPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.LeftPunch)
LeftPunch:Play()
Combo = 1
wait(0.5)
CD = false
end
end
end
end)
I put it just downside the CD true and now it’s working ty
local Equipped = false
local CombaTOOL = script.Parent
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local Char = Player.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local Combo = 1
local CD = false
CombaTOOL.Equipped:Connect(function()
Equipped = true
end)
CombaTOOL.Unequipped:Connect(function()
Equipped = false
end)
UIS.InputBegan:Connect(function(Input, GameProcessed)
if Equipped then
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
if CD == false then
CD = true
wait(0.5)
CD = false
RS.CRemote:FireServer()
print("!!!")
if Combo == 1 then
local RightPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.RightPunch)
RightPunch:Play()
Combo = 2
elseif Combo == 2 then
local LeftPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.LeftPunch)
LeftPunch:Play()
Combo = 1
end
end
end
end
end)
Wait, but now you will punch AFTER 0.5 seconds. you should put the 0.5 wait after it.
local Equipped = false
local CombaTOOL = script.Parent
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local Char = Player.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local Combo = 1
local CD = false
CombaTOOL.Equipped:Connect(function()
Equipped = true
end)
CombaTOOL.Unequipped:Connect(function()
Equipped = false
end)
UIS.InputBegan:Connect(function(Input, GameProcessed)
if Equipped then
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
if CD == false then
CD = true
RS.CRemote:FireServer()
print("!!!")
if Combo == 1 then
local RightPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.RightPunch)
RightPunch:Play()
Combo = 2
elseif Combo == 2 then
local LeftPunch = Hum:WaitForChild("Animator"):LoadAnimation(CombaTOOL.LeftPunch)
LeftPunch:Play()
Combo = 1
end
wait(0.5)
CD = false
end
end
end
end)