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 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)
- local combo = char:GetAttribute("Combo")
- local punchAnims = animations:WaitForChild("Combat"):GetChildren()
- local currAnim = punchAnims[combo]
- return currAnim
- end
- local function stopAnims(object)
- for i,v in pairs(object:GetPlayingAnimationTracks()) do
- v:Stop()
- end
- end
- punchRemote.OnServerEvent:Connect(function(player)
- 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 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
- 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 playPunchAnim = hum:LoadAnimation(getPunchAnim(char))
- playPunchAnim.KeyframeReached:Connect(function(kf)
- if kf == "Hit" then
- char:SetAttribute("Attacking",false)
- 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