local rp = game:GetService("ReplicatedStorage")
local Combat = rp:WaitForChild("Combat")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local Animations = script:WaitForChild("Animations")
local EnemyAnims = script:WaitForChild("EnemyAnims")
local Meshes = script:WaitForChild("Meshes")
local anims =
{
Animations:WaitForChild("Right"),
Animations:WaitForChild("Left"),
Animations:WaitForChild("Gut"),
Animations:WaitForChild("Kick")
}
local eAnims =
{
EnemyAnims:WaitForChild("EnemyRight"),
EnemyAnims:WaitForChild("EnemyLeft"),
EnemyAnims:WaitForChild("EnemyGut"),
EnemyAnims:WaitForChild("EnemyKick"),
EnemyAnims:WaitForChild("Break")
}
local limbs =
{
"RightHand",
"LeftHand",
"RightHand",
"RightFoot"
}
Combat.OnServerEvent:Connect(function(player,count)
local Exp = player:WaitForChild('PlrStats').Exp.Value
local Damage = player:WaitForChild('PlrStats').Level.Value
local Character = player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Humrp = Character:WaitForChild("HumanoidRootPart")
local attack = Humanoid:LoadAnimation(anims[count])
attack:Play()
local Limb = Character:WaitForChild(limbs[count])
local folder = Instance.new("Folder",Character)
folder.Name = player.Name.." Melee"
Debris:AddItem(folder,.5)
local Hitbox = Meshes:WaitForChild("Hitbox"):Clone()
Hitbox.CFrame = Limb.CFrame
Hitbox.Parent = folder
Debris:AddItem(Hitbox,.5)
local weld = Instance.new("ManualWeld")
weld.Part0 = Hitbox
weld.Part1 = Limb
weld.C0 = weld.Part0.CFrame:toObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
Hitbox.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Character) then
local enemyHumanoid = Hit.Parent:FindFirstChild("Humanoid")
local enemyHumrp = Hit.Parent:FindFirstChild("HumanoidRootPart")
if enemyHumanoid and enemyHumrp then
local blockAction = enemyHumanoid:FindFirstChild("blockAction")
if blockAction then
--/Count towardds bracking
Hitbox:Destroy()
if blockAction.Value > 0 then
blockAction.Value = blockAction.Value - 1
if blockAction.Value == 0 then
local Break = enemyHumanoid:LoadAnimation(eAnims[5])
Break:Play()
blockAction:Destroy()
spawn(function()
for i, anims in pairs(Humanoid:GetPlayingAnimationTracks()) do
if anims.Name == "Block" then
anims:Stop()
end
end
local enemy = game:GetService("Players"):GetPlayerFromCharacter(enemyHumanoid.Parent)
if enemy then
local backpack = enemy:FindFirstChild("Backpack")
if backpack then
local CombatSystem = backpack:FindFirstChild("CombatSystem")
if CombatSystem then
local isBroken = CombatSystem:FindFirstChild("isBrocken")
if isBroken then
isBroken.Value = true
--//Stun
wait(3)
isBroken.Value = false
end
end
end
end
end)
local effects = Instance.new("Folder",workspace)
effects.Name = player.Name.." Effects"
Debris:AddItem(effects,.5)
local Wave = Meshes:WaitForChild("Wave")
Wave.CFrame = enemyHumrp.CFrame
Wave.Orientation = Wave.Orientation + Vector3.new(-90,0,0)
Wave.Parent = folder
local goal = {}
goal.Size = Wave.Size + Vector3.new(10,0,10)
local info = TweenInfo.new(.5)
local tween = TweenService:Create(Wave,info,goal)
tween:Play()
end
end
else
--/Do damage since they are not blocking
Hitbox:Destroy()
enemyHumanoid:TakeDamage(Damage)
--/only npc and dummies can recieve attacker value for exp
if not Players:GetPlayerFromCharacter(enemyHumanoid.Parent) then
if not enemyHumanoid:FindFirstChild(player.Name) then
local attacker = Instance.new("StringValue",enemyHumanoid)
attacker.Name = player.Name
Debris:AddItem(attacker,5)
else
local prevAttacker = enemyHumanoid:FindFirstChild(player.Name)
Debris:AddItem(prevAttacker,.1)
local attacker = Instance.new("StringValue",enemyHumanoid)
attacker.Name = player.Name
Debris:AddItem(attacker,5)
end
end
local react = enemyHumanoid:LoadAnimation(eAnims[count])
react:Play()
if count == 4 then
local goal = {}
goal.CFrame = CFrame.new((Humrp.CFrame * CFrame.new(0,0,-15)).p, Humrp.CFrame.p)
local info = TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local tween = TweenService:Create(enemyHumrp,info,goal)
tween:Play()
end
end
end
end
end
end)
Combat:FireClient(player)
end)
line 38 has the local exp already have the value just need code to increase by 1 each time i punch which is F there is also a delay between each punch.
local exp may not be in the right spot though so change it if you need to.

1 comment
FireClient fires OnClientEvent not OnServerEvent