Hello!
I was making my knife
But there is one little problem
When I activated and I don’t hit anyone and then I hit anyone it¨s still taking demage
I’m doing when hit and take demage is succesful I disconnecting all conections already too in UnEquiped
Here is my script
wait(5)
local Tool = script.Parent
local EquipAnimation = script.Parent.EquipAnimation
local AttackAnimation = script.Parent["Attack #1"]
local Cooldown = 2
local Debaunce = false
local LastPlayerDemaged = nil
local TakeDemage = game.ReplicatedStorage.TakeDemage
local PlayAnimation = game.ReplicatedStorage.PlayAnimation
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Connection = nil
local Connection2 = nil
Tool.Equipped:Connect(function()
PlayAnimation:FireServer(EquipAnimation)
script.Parent["Equip&UnEquip"]:Play()
Connection = Tool.Activated:Connect(function()
if Debaunce == false and Player then
PlayAnimation:FireServer(AttackAnimation)
Connection2 = script.Parent.Handle.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= Player.Name then
script.Parent.Attack:Play()
TakeDemage:FireServer(hit.Parent)
Connection:Disconnect()
Connection2:Disconnect()
Debaunce = true
wait(Cooldown)
Debaunce = false
end
end)
end
end)
end)
Tool.Unequipped:Connect(function()
if Connection ~= nil and Connection2 ~= nil then
Connection:Disconnect()
Connection2:Disconnect()
end
end)
Thanks!