Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Tool = script.Parent
- local Player = script.Parent.Parent.Parent
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- repeat wait() until Humanoid
- local RS = game:GetService("ReplicatedStorage")
- local Debris = game:GetService("Debris")
- local TWEEN = game:GetService("TweenService")
- local Combo = 0
- local CD = false
- local LastHit = 0
- local Damage = 2
- local BodyToughness = 0 -- Not used for now
- local Shake = RS.Effects.ShakeScript
- local Rush = RS.Gui.RushEffect
- local RegionModule = require(game.ReplicatedStorage.RegionModule)
- local function findFirstCharacterInRegion(partsList)
- for _, part in next, partsList do
- if part.Parent and part.Parent:FindFirstChild"Humanoid" then
- return part.Parent
- end
- end
- end
- local function createRay(startPos, direction, distance, ignore)
- local ray = Ray.new(startPos, direction.unit * distance)
- local hitPart, hitPosition, normal, material = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
- return hitPart, hitPosition, normal, material
- end
- Tool.Activated:Connect(function()
- local Velocity = Character.HumanoidRootPart.Velocity
- local Unit = Velocity.magnitude > 0 and Velocity.unit or Vector3.new(0, 0, 0)
- local Dot = Unit:Dot(Character.HumanoidRootPart.CFrame.lookVector)
- local Dot2 = Character.HumanoidRootPart.CFrame.rightVector:Dot(Unit)
- local CF = Character.HumanoidRootPart.CFrame * CFrame.new(0, 1, -2.5)
- if math.abs(Dot) > 0 then
- if math.floor(Dot + 0.5) == 1 then
- CF = CF + Character.HumanoidRootPart.CFrame.lookVector * 4.5
- elseif math.floor(Dot + 0.5) == -1 then
- CF = CF + Character.HumanoidRootPart.CFrame.lookVector * -3
- end
- end
- local Region = RegionModule.new(CF, Vector3.new(5.5, 5, 5.5))
- local hitCharacter = findFirstCharacterInRegion(Region:Cast(Character))
- if CD == true then return end
- CD = true
- if tick() - LastHit < .3 then
- Combo = Combo + 1
- print(Combo)
- else
- Combo = 1
- end
- LastHit = tick() + .8
- local AnimPlay = Humanoid:LoadAnimation(Tool["Punch"..(Combo)])
- AnimPlay:Play()
- if hitCharacter then
- local hitPlayer = game.Players:GetPlayerFromCharacter(hitCharacter)
- local Effects = RS.Effects["Combat"].CombatEffect:Clone()
- hitCharacter:FindFirstChild("Humanoid"):TakeDamage(Damage - BodyToughness)
- if hitPlayer then
- local Swag = Effects
- Debris:AddItem(Swag, 2)
- Swag.Parent = hitCharacter.UpperTorso
- Swag.CFrame = hitCharacter:FindFirstChild("UpperTorso").CFrame
- Swag.Anchored = true
- --[==[
- local weld = Instance.new("Weld", Swag)
- weld.Part0 = Swag
- weld.Part1 = hitCharacter.UpperTorso]==]
- local Huh = Shake:Clone()
- Debris:AddItem(Huh, 2)
- Huh.Parent = hitCharacter
- Huh.Disabled = false
- local Huh2 = Rush:Clone()
- Debris:AddItem(Huh2, 2)
- Huh2.Parent = hitPlayer.PlayerGui
- Huh2.Image.LocalScript.Disabled = false
- end
- end
- if hitCharacter and Combo == 5 then
- local KnockedBack = Instance.new("Folder")
- Debris:AddItem(KnockedBack, 2)
- KnockedBack.Parent = hitCharacter.Humanoid
- KnockedBack.Name = "Knockedback"
- --[==[local BVEnemy = Instance.new("BodyVelocity")
- BVEnemy.MaxForce = Vector3.new(1e7, 1e7, 1e7)
- BVEnemy.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 45 + Vector3.new(0,12,0)
- Debris:AddItem(BVEnemy, .65)
- BVEnemy.Parent = hitCharacter.HumanoidRootPart]==]
- local Stun = hitCharacter.Humanoid:LoadAnimation(Tool["Stun"..math.random(1,2)])
- Stun:Play()
- end
- if Combo == 5 then
- Combo = 1
- if hitCharacter and hitCharacter.Humanoid.Knockedback then
- local hitPart, hitPosition = createRay(Character.HumanoidRootPart.Position, Character.HumanoidRootPart.Position, 20, {workspace.Characters})
- local distance = (hitCharacter.HumanoidRootPart.Position - hitPosition).magnitude
- local tween = TWEEN:Create(hitCharacter.HumanoidRootPart, TweenInfo.new(distance/40, Enum.EasingStyle.Linear), {Position = hitPosition})
- tween:Play()
- tween.Completed:Connect(function()
- if hitPart then
- print("hirayworked")
- end
- end)
- hitCharacter.Humanoid.Touched:Connect(function(hitPart)
- if hitPart:FindFirstChild("UpperTorso") then
- end
- end)
- end
- end
- if Combo == 4 then
- wait(.3)
- end
- wait(.38)
- CD = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement