If i equip my knife, then unequip it, i can still hit people with empty hand, my code is that :
local cas = game:GetService("ContextActionService")
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local leftSwing = animator:LoadAnimation(script:WaitForChild("LeftSwing"))
local rightSwing = animator:LoadAnimation(script:WaitForChild("RightSwing"))
local currentSwing = 0
local lastSwing = 0
local debounce = false
local function swing()
if debounce then return end
if not character:FindFirstChild("Knife") then return end
if tick() - lastSwing > 1.5 then
currentSwing = 0
end
debounce = true
if currentSwing == 0 then
rightSwing:Play()
hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 20, 140)
task.wait(0.4)
debounce = false
elseif currentSwing == 1 then
leftSwing:Play()
hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 20, 140)
task.wait(0.4)
debounce = false
elseif currentSwing == 2 then
rightSwing:Play()
hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 20, 140)
task.wait(0.8)
debounce = false
end
if currentSwing == 2 then
currentSwing = 0
else
currentSwing += 1
end
lastSwing = tick()
end
cas:BindAction("Swing", swing, true, Enum.UserInputType.MouseButton1)
** You are now Level 1! **