Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local rp = game:GetService("ReplicatedStorage")
- local remotes = rp:WaitForChild("Remotes")
- local animations = rp:WaitForChild("Animations")
- local punchRemote = remotes:WaitForChild("Punch")
- local debris = game:GetService("Debris")
- local ss = game:GetService("ServerStorage")
- local modules = ss:WaitForChild("Modules")
- local TomatoHitbox = require(modules:WaitForChild("TomatoHitbox"))
- local hitService = require(modules:WaitForChild("HitService"))
- local lastPunch = {}
- local MAX_COMBO = 4
- local function changeCombo(char)
- local combo = char:GetAttribute("Combo")
- local player = game:GetService("Players"):GetPlayerFromCharacter(char)
- if lastPunch[player] then
- local passedTime = os.clock() - lastPunch[player]
- print(passedTime)
- if passedTime <= 1.25 then
- if combo >= MAX_COMBO then
- char:SetAttribute("Combo",1)
- else
- char:SetAttribute("Combo",combo + 1)
- end
- else
- char:SetAttribute("Combo",1)
- end
- else
- if combo >= MAX_COMBO then
- char:SetAttribute("Combo",1)
- else
- char:SetAttribute("Combo",combo + 1)
- end
- end
- lastPunch[player] = os.clock()
- end
- local function getPunchAnim(char,jump)
- local combo = char:GetAttribute("Combo")
- local punchAnims = animations:WaitForChild("Combat"):GetChildren()
- local extraAnims = animations:WaitForChild("Extra")
- local inAir = char.Humanoid.FloorMaterial == Enum.Material.Air
- local currAnim
- if combo == MAX_COMBO then
- if not inAir then
- if not jump then
- currAnim = punchAnims[combo]
- else
- currAnim = extraAnims:WaitForChild("UpperCut")
- end
- else
- currAnim = extraAnims:WaitForChild("DownSlam")
- end
- else
- currAnim = punchAnims[combo]
- end
- return currAnim
- end
- local function stopAnims(object)
- for i,v in pairs(object:GetPlayingAnimationTracks()) do
- v:Stop()
- end
- end
- punchRemote.OnServerEvent:Connect(function(player,jump)
- local char = player.Character
- local hum = char:WaitForChild("Humanoid")
- local humRp = char:WaitForChild("HumanoidRootPart")
- local attacking = char:GetAttribute("Attacking")
- local punching = char:GetAttribute("Punch")
- local stunned = char:GetAttribute("Stunned")
- if attacking or punching or stunned then return end
- char:SetAttribute("Attacking",true)
- char:SetAttribute("Punch",true)
- changeCombo(char)
- stopAnims(hum)
- hum.WalkSpeed = 10
- hum.JumpPower = 0
- local ragdoll = false
- local downSlam = false
- local upperCut = false
- local newHitbox = TomatoHitbox.new()
- newHitbox.Size = Vector3.new(6,6,6)
- newHitbox.CFrame = humRp
- newHitbox.Offset = CFrame.new(0,0,-2.5)
- newHitbox.onTouch = function(enemyHum)
- if enemyHum ~= hum then
- if enemyHum.Parent:GetAttribute("Ragdolled") or enemyHum.Health <= 0 then return end
- local enemyHumRp = enemyHum.Parent.HumanoidRootPart
- local center = (enemyHumRp.Position - humRp.Position).Unit
- local strength = 10
- if char:GetAttribute("Combo") == MAX_COMBO then
- ragdoll = true
- strength = 35
- end
- local knockback = center * strength
- if downSlam then
- enemyHumRp.CFrame = enemyHumRp.CFrame * CFrame.new(0,-2,0) * CFrame.Angles(math.rad(90),0,0)
- knockback = nil
- elseif upperCut then
- local uppercutVelocity = Instance.new("BodyVelocity")
- uppercutVelocity.P = 50000
- uppercutVelocity.MaxForce = Vector3.new(0,math.huge,0)
- uppercutVelocity.Velocity = Vector3.new(0,50,0)
- uppercutVelocity.Parent = enemyHumRp
- debris:AddItem(uppercutVelocity,0.2)
- knockback = nil
- end
- hitService.Hit(enemyHum,2,1.25,knockback,ragdoll,2)
- if char:GetAttribute("Combo") ~= MAX_COMBO then
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(math.huge,0,math.huge)
- bv.P = 50000
- bv.Velocity = knockback
- bv.Parent = humRp
- debris:AddItem(bv,0.2)
- end
- end
- end
- local combatAnim = getPunchAnim(char,jump)
- local playPunchAnim = hum:LoadAnimation(combatAnim)
- playPunchAnim.KeyframeReached:Connect(function(kf)
- if kf == "Hit" then
- char:SetAttribute("Attacking",false)
- if combatAnim.Name == "DownSlam" then
- downSlam = true
- elseif combatAnim.Name == "UpperCut" then
- upperCut = true
- end
- task.spawn(function()
- if not char:GetAttribute("Stunned") then
- newHitbox:Start()
- task.wait(0.1)
- newHitbox:Stop()
- newHitbox:Destroy()
- else
- newHitbox:Stop()
- newHitbox:Destroy()
- end
- end)
- if char:GetAttribute("Combo") == MAX_COMBO then
- task.wait(1)
- end
- char:SetAttribute("Punch",false)
- end
- end)
- playPunchAnim.Stopped:Connect(function()
- hum.WalkSpeed = 16
- hum.JumpPower = 50
- end)
- playPunchAnim:Play()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement