local Player = game:GetService("Players").LocalPlayer
local rp = game:GetService("ReplicatedStorage")
local Combat = rp:WaitForChild("Combat")
local UIS = game:GetService("UserInputService")
local debounce = false
local cd = .25
local currTime = 0
local prevTime = 0
local count = 0
local Equipped = false
if script.Parent.Equipped:Connect(function()
Equipped = true
end)
script.Parent.Unequipped:Connect(function()
Equipped = false
end)
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then
return
elseif Equipped and input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce == false then
debounce = true
currTime = tick()
local passedTime = currTime - prevTime
if passedTime < 1 then
--Can Continue the Combat Combo
count = count + 1
if count > 4 then
count = 1
end
else
--Restarts the combo
count = 1
end
Combat:FireServer(count)
end
end
end)
Combat.OnClientEvent:Connect(function()
prevTime = currTime
wait(cd)
debounce = false
end)
I'm trying to get this script to only activate when i have a certain tool equipped help please i already have some code to try to get this to work but it doesn't.
