To Expand, i created a punch tool. When you activate the tool, it fires an animation and does some damage.
Either it's not damaging the dummies, instead it damages me, it's still active, even after i unequip it.
I've been constantly working on this 24/7 and then i found out i could get some help on this site. not only for a good feel, but for future reference.
Local Script:
local Animation = script.Animation local Replicated = game:GetService("ReplicatedStorage") local RemoteEvent = Replicated.Remotes.Punch local Debounce = false wait(2) local Humanoid = game.Players.LocalPlayer.Character.Humanoid script.Parent.Activated:Connect(function() if not Debounce then Debounce = true local AnimationTrack = Humanoid:LoadAnimation(Animation) RemoteEvent:FireServer() wait(2) Debounce = false end end)
Server Script:
local Tools = game:GetService("ReplicatedStorage"):WaitForChild("Tools") local RemoteEvent = game:GetService("ReplicatedStorage").Remotes.Punch local Animation = Tools.SuperPunch.PunchConnecter.Animation wait(1) RemoteEvent.OnServerEvent:Connect(function(player) local Hum = player.Character.Humanoid local AnimationTrack = Hum:LoadAnimation(Animation) AnimationTrack:Play() if AnimationTrack.IsPlaying then local LeftArm = player.Character["RightHand"] LeftArm.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then Hum:TakeDamage(20) Hum.Sit = true end end) end end)
I personally prefer handling it all on a single script inside the tool
--Script local tool = script.Parent; local Animation = game.ReplicatedStorage:WaitForChild("Tools"):WaitForChild("SuperPunch"):WaitForChild("PunchConnecter"):WaitForChild("Animation") local char local humanoid = char:WaitForChild("Humanoid") local RArm local canAttack = true local attacking = false local equipped = false tool.Equipped:Connect(function() equipped = true RArm = = char:WaitForChild("RightHand") char = tool.Parent end) tool.Unequipped:Connect(function() equipped = false attacking = false end) tool.Activated:Connect(function() if canAttack then canAttack = false attacking = true local AnimationTrack = Humanoid:LoadAnimation(Animation) AnimationTrack:Play() RArm.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum and hit.Parent ~= char and equipped and attacking then hum:TakeDamage(20) hum.Sit = true end end) wait(1) canAttack = true attacking = false end end)
You have to ignore the player on server
local Tools = game:GetService("ReplicatedStorage"):WaitForChild("Tools") local RemoteEvent = game:GetService("ReplicatedStorage").Remotes.Punch local Animation = Tools.SuperPunch.PunchConnecter.Animation wait(1) RemoteEvent.OnServerEvent:Connect(function(player) local Hum = player.Character.Humanoid local AnimationTrack = Hum:LoadAnimation(Animation) AnimationTrack:Play() if AnimationTrack.IsPlaying then local LeftArm = player.Character["RightHand"] LeftArm.Touched:Connect(function(hit) if hit.Parent.Name == player.Name or hit.Parent.Parent.Name == player.Name then return end if hit.Parent:FindFirstChild("Humanoid") then Hum:TakeDamage(20) Hum.Sit = true end end) end end)