Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local remote = game.ReplicatedStorage.Remotes.Combat.CombatEvent
- local knockbackRemote = game.ReplicatedStorage.Remotes.Combat.KnockbackEvent
- local dummyKnockbackRemote = game.ReplicatedStorage.BindableEvents.Combat.DummyKnockback
- local normalDmg = 4
- local heavyDmg = 6
- local barrageDmg = 1.5
- local addRageAmount = 3.5
- local barrageAddRageAmount = addRageAmount / 16
- local normalKnockback = 50
- local heavyKnockback = 100
- local stunLength = 1
- local parryLength = 2
- local blockBreakLength = 2
- local thread: thread
- local function GetDamage(char)
- return char:GetAttribute("Rage") / 100
- end
- local function AddRage(char, amount)
- return char:GetAttribute("Rage") + amount
- end
- remote.OnServerEvent:Connect(function(plr: Player, hit: BasePart, punchType: string, direction: string, combo: number)
- local char = plr.Character
- local hum = char.Humanoid
- local humrp = char.HumanoidRootPart
- local echar = hit.Parent
- local ehum: Humanoid = echar.Humanoid
- local ehumrp = echar.HumanoidRootPart
- if echar:GetAttribute("State") == "IFrames" or echar:GetAttribute("NPC") then
- return
- end
- local hitVFX = game.ReplicatedStorage.VFX.Hit:Clone()
- local hitFx: Sound
- if punchType == "Normal" or punchType == "Heavy" then
- hitFx = game.SoundService.Combat["M" .. combo]:Clone()
- elseif punchType == "StandHeavy" then
- hitFx = game.SoundService.Combat.M4:Clone()
- else
- hitFx = game.SoundService.Combat.HitSound:Clone()
- end
- if ehum.Health <= normalDmg and punchType == "Normal" or ehum.Health <= heavyDmg and punchType == "Heavy" then
- hitFx = game.SoundService.Combat.M4:Clone()
- if not echar:FindFirstChild("Dummy") then
- knockbackRemote:FireClient(game.Players:GetPlayerFromCharacter(echar), char.Torso.CFrame.LookVector * heavyKnockback)
- else
- dummyKnockbackRemote:Fire(char.Torso.CFrame.LookVector * heavyKnockback, echar.Dummy.Value)
- end
- end
- if punchType == "StandHeavy" then
- if echar:GetAttribute("State") == "Blocking" then
- if direction == "Front" then
- if echar:GetAttribute("Parry") == true then
- local parrySFX = game.SoundService.Combat.Parry:Clone()
- parrySFX.Parent = echar
- parrySFX:Destroy()
- char:SetAttribute("State", "Stunned")
- task.delay(parryLength, function()
- char:SetAttribute("State", "Default")
- end)
- return
- end
- end
- end
- echar:SetAttribute("State", "Stunned")
- task.delay(stunLength, function()
- echar:SetAttribute("State", "Default")
- end)
- hitFx.Parent = echar
- hitFx:Destroy()
- hitVFX.Parent = ehumrp
- hitVFX.Position = ehumrp.Position
- game.Debris:AddItem(hitVFX, 0.4)
- ehum:TakeDamage(heavyDmg + GetDamage(char))
- char:SetAttribute("Rage", AddRage(char, addRageAmount))
- if thread then
- task.cancel(thread)
- end
- if ehum.Health > 10 then
- if not echar:FindFirstChild("Dummy") then
- knockbackRemote:FireClient(game.Players:GetPlayerFromCharacter(echar), char.Torso.CFrame.LookVector * normalKnockback)
- else
- dummyKnockbackRemote:Fire(char.Torso.CFrame.LookVector * normalKnockback, echar.Dummy.Value)
- end
- echar.IsRagdoll.Value = true
- task.wait(3)
- echar.IsRagdoll.Value = false
- end
- elseif punchType == "Barrage" then
- if echar:GetAttribute("State") == "Blocking" then
- if direction == "Front" then
- if echar:GetAttribute("Parry") == true then
- local parrySFX = game.SoundService.Combat.Parry:Clone()
- parrySFX.Parent = echar
- parrySFX:Destroy()
- char:SetAttribute("State", "Stunned")
- task.delay(parryLength, function()
- char:SetAttribute("State", "Default")
- end)
- return
- end
- local blockSFX = game.SoundService.Combat.Block:Clone()
- blockSFX.Parent = echar
- blockSFX:Destroy()
- return
- end
- end
- hitFx.Parent = echar
- hitFx:Destroy()
- hitVFX.Parent = ehumrp
- hitVFX.Position = ehumrp.Position
- game.Debris:AddItem(hitVFX, 0.4)
- ehum:TakeDamage(barrageDmg + GetDamage(char))
- char:SetAttribute("Rage", AddRage(char, barrageAddRageAmount))
- if thread then
- task.cancel(thread)
- end
- echar:SetAttribute("State", "Stunned")
- thread = task.delay(stunLength, function()
- echar:SetAttribute("State", "Default")
- end)
- elseif punchType == "Heavy" then
- if echar:GetAttribute("State") == "Blocking" then
- if echar:GetAttribute("Parry") == true and direction == "Front" then
- local parrySFX = game.SoundService.Combat.Parry:Clone()
- parrySFX.Parent = echar
- parrySFX:Destroy()
- char:SetAttribute("State", "Stunned")
- thread = task.delay(parryLength, function()
- char:SetAttribute("State", "Default")
- end)
- return
- end
- echar:SetAttribute("State", "Stunned")
- thread = task.delay(blockBreakLength, function()
- echar:SetAttribute("State", "Default")
- end)
- hitFx.Parent = echar
- hitFx:Destroy()
- hitVFX.Parent = ehumrp
- hitVFX.Position = ehumrp.Position
- game.Debris:AddItem(hitVFX, 0.4)
- ehum:TakeDamage(heavyDmg + GetDamage(char))
- char:SetAttribute("Rage", AddRage(char, addRageAmount))
- if thread then
- task.cancel(thread)
- end
- return
- end
- echar:SetAttribute("State", "Stunned")
- task.delay(stunLength, function()
- echar:SetAttribute("State", "Default")
- end)
- hitFx.Parent = echar
- hitFx:Destroy()
- hitVFX.Parent = ehumrp
- hitVFX.Position = ehumrp.Position
- game.Debris:AddItem(hitVFX, 0.4)
- ehum:TakeDamage(heavyDmg + GetDamage(char))
- char:SetAttribute("Rage", AddRage(char, addRageAmount))
- if thread then
- task.cancel(thread)
- end
- if ehum.Health > 10 then
- if not echar:FindFirstChild("Dummy") then
- knockbackRemote:FireClient(game.Players:GetPlayerFromCharacter(echar), char.Torso.CFrame.LookVector * normalKnockback)
- else
- dummyKnockbackRemote:Fire(char.Torso.CFrame.LookVector * normalKnockback, echar.Dummy.Value)
- end
- echar.IsRagdoll.Value = true
- task.wait(3)
- echar.IsRagdoll.Value = false
- end
- elseif punchType == "Normal" then
- if echar:GetAttribute("State") == "Blocking" then
- if direction == "Front" then
- if echar:GetAttribute("Parry") == true then
- local parrySFX = game.SoundService.Combat.Parry:Clone()
- parrySFX.Parent = echar
- parrySFX:Destroy()
- char:SetAttribute("State", "Stunned")
- task.delay(parryLength, function()
- char:SetAttribute("State", "Default")
- end)
- return
- end
- local blockSFX = game.SoundService.Combat.Block:Clone()
- blockSFX.Parent = echar
- blockSFX:Destroy()
- return
- end
- end
- hitFx.Parent = echar
- hitFx:Destroy()
- hitVFX.Parent = ehumrp
- hitVFX.Position = ehumrp.Position
- game.Debris:AddItem(hitVFX, 0.4)
- ehum:TakeDamage(normalDmg + GetDamage(char))
- char:SetAttribute("Rage", AddRage(char, addRageAmount))
- if thread then
- task.cancel(thread)
- end
- echar:SetAttribute("State", "Stunned")
- thread = task.delay(stunLength, function()
- echar:SetAttribute("State", "Default")
- end)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement