I am trying to make a little game and I was almost done with it but all the weapons attack the same speed is there any way to make a weapon hit slow or fast? Or a video that explains it here is my basic attack code.

local tool = script.Parent
local canDamage = false
    
local function onTouch(otherPart)
  
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
 
    if not humanoid then 
        return 
    end
 
    if humanoid.Parent ~= tool.Parent and canDamage then 
        humanoid:TakeDamage(5)
    else
        return
    end
 
    canDamage = false
end


local function slash()
    local str = Instance.new("StringValue")
    str.Name = "toolanim"
    str.Value = "Slash" 
    str.Parent = tool
    canDamage = true
end


tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)

4 comments

0

Maybe add a wait()?

0

Where tho i am very new to scripting

0

Do you mean animation speed or time between attacks is too low?

0

Time between attacks