When I have these scripts under the name Animate in every NPC on my game to have the NPC attack us, but when multiple NPCs are fighting even on opposite sides of the map their damages combine on every player fighting them... I am STUMPED.
Script:
local Animations = game.ReplicatedStorage.Animations local WalkAnim = Animations.Walk local IdleAnim = Animations.Idle local RunAnim = Animations.Run local RPunch = Animations.RPunch local LPunch = Animations.LPunch local LKick = Animations.LKick local LHook = Animations.LHook local Character = script.Parent local OuterSpeed local ShiftIsDown = false Character.Humanoid.Running:Connect(function(Speed) OuterSpeed = Speed if Speed >= 1 and ShiftIsDown == false then for i,v in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end local AnimLoad = Character.Humanoid:LoadAnimation(WalkAnim) AnimLoad:Play() end if Speed == 0 then for i,v in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end local AnimLoad1 = Character.Humanoid:LoadAnimation(IdleAnim) AnimLoad1:Play() end end) local Attacker = script.Parent.Reward.Attacker local canBegin = true script.Parent.Humanoid.HealthChanged:Connect(function() if canBegin == false then return end canBegin = false local Value = Attacker.Value local Target = workspace:FindFirstChild(Value) local RS = game:GetService("RunService") local TCount = 0 local midAnim local db = false _G.dmgLock4 = false _G.dmgLock3 = false _G.dmgLock2 = false local Locked = true while Locked == true do script.Parent.Humanoid:MoveTo(Target.HumanoidRootPart.Position) if db == true then return end TCount = TCount + 1 local A = game.ReplicatedStorage.Sounds.PunchSwung:Clone() A.Parent = Character.HumanoidRootPart A:Play() A.Ended:Connect(function() A:Destroy() end) if TCount == 1 then db = true midAnim = true for i,v in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end local AnimLoad = Character.Humanoid:LoadAnimation(RPunch) AnimLoad:Play() if _G.dmgLock4 == false then script.Parent["Right Arm"].Touched:Connect(function(Hit) if _G.dmgLock4 == true then return end if Hit.Parent.ClassName == "Model" then _G.dmgLock4 = true wait() local T = Hit.Parent local TGrit = T.Values.Grit.Value local LStrength = Character.Values.Strength.Value if midAnim == true then local DamageDone = script.Parent.Values.Strength.Value * 3 - Hit.Parent.Values.Grit.Value * .25 local A = game.ReplicatedStorage.Sounds.PunchLanded:Clone() A.Parent = script.Parent.HumanoidRootPart A:Play() A.Ended:Connect(function() A:Destroy() end) Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - DamageDone wait(1) else return false end end Hit.Parent.Humanoid.Died:Connect(function() Locked = false canBegin = true end) end) end wait() midAnim = false _G.dmgLock4 = false db = false end if TCount == 2 then db = true midAnim = true for i,v in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end local AnimLoad = Character.Humanoid:LoadAnimation(LPunch) AnimLoad:Play() if _G.dmgLock3 == false then script.Parent["Left Arm"].Touched:Connect(function(Hit) if _G.dmgLock3 == true then return end if Hit.Parent.ClassName == "Model" then _G.dmgLock3 = true wait() local T = Hit.Parent local TGrit = T.Values.Grit.Value local LStrength = Character.Values.Strength.Value if midAnim == true then local DamageDone = script.Parent.Values.Strength.Value * 3 - Hit.Parent.Values.Grit.Value * .25 local A = game.ReplicatedStorage.Sounds.PunchLanded:Clone() A.Parent = script.Parent.HumanoidRootPart A:Play() A.Ended:Connect(function() A:Destroy() end) Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - DamageDone wait(1) else return false end end Hit.Parent.Humanoid.Died:Connect(function() Locked = false canBegin = true end) end) end wait() midAnim = false _G.dmgLock3 = false db = false end if TCount == 3 then db = true midAnim = true for i,v in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end local AnimLoad = Character.Humanoid:LoadAnimation(LKick) AnimLoad:Play() if _G.dmgLock2 == false then script.Parent["Left Leg"].Touched:Connect(function(Hit) if _G.dmgLock2 == true then return end if Hit.Parent.ClassName == "Model" then _G.dmgLock2 = true wait() local T = Hit.Parent local TGrit = T.Values.Grit.Value local LStrength = Character.Values.Strength.Value if midAnim == true then local DamageDone = script.Parent.Values.Strength.Value * 3 - Hit.Parent.Values.Grit.Value * .25 local A = game.ReplicatedStorage.Sounds.PunchLanded:Clone() A.Parent = script.Parent.HumanoidRootPart A:Play() A.Ended:Connect(function() A:Destroy() end) Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - DamageDone wait(1) else return false end end Hit.Parent.Humanoid.Died:Connect(function() Locked = false canBegin = true end) end) end wait() midAnim = false _G.dmgLock2 = false db = false TCount = 0 end end end)