So basically I need to do the action and if no player is detected then cancel it because if you click then touch them after like 100 seconds then it still does damage even though there is no player here is script:
Normal:
local A = script.Parent:WaitForChild("Attack")
local Tool = script.Parent
local B = script.Parent.Blade
local Damage = 10
local Debounce = false
local Cooldown = 2
A.OnServerEvent:Connect(function(player)
B.Touched:Connect(function(hit)
if(hit.Parent.Name ~= player.Name)then
if(Debounce == false)then
Debounce = true
local H = hit.Parent:WaitForChild("Humanoid")
H:TakeDamage(Damage)
wait(Cooldown)
Debounce = false
end
end
end)
end)
Local:
local Tool = script.Parent
local Debounce = false
local Cooldown = 2
local A = script.Parent:WaitForChild("Attack")
local Stab = script:WaitForChild("Stab")
local P = game.Players.LocalPlayer
local H = P.Character:WaitForChild("Humanoid")
local Anim = H:LoadAnimation(Stab)
Tool.Activated:Connect(function()
if(Debounce == false)then
Debounce = true
Anim:Play()
A:FireServer()
wait(Cooldown)
Debounce = false
end
end)
