Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Tool: Tool = script.Parent
- local Player = Tool.Parent.Parent
- local Char: Model = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid = Char:WaitForChild("Humanoid")
- local RunService = game:GetService("RunService")
- local Debris = game:GetService("Debris")
- local RS = game:GetService("ReplicatedStorage")
- local IsPunched = Char:WaitForChild("IsPunched");
- local Combo: number = 0;
- local Debounce: boolean = nil;
- local changeDebounce: boolean = nil
- local Main: RBXScriptConnection = nil
- local DMG = 5; -- amount of dmg
- local extraDMG = 2 -- Extra dmg at the last m1
- local Gwait = .3 -- General Wait
- local Fwait = 3 -- Final Wait
- local resetWait = 1.2 --7 -- Wait Time until combo resets
- local function findPlayerFixBox(): boolean -- Finds enemycharacter and increments 1 to combo when found, if not we reset everything to nil
- local Params = OverlapParams.new();
- Params.FilterDescendantsInstances = {Char, game.Workspace.Baseplate}
- Params.FilterType = Enum.RaycastFilterType.Blacklist
- local InArea,EnemyCharacter,EnemyPlayer;
- for Index,Value in pairs(game.Workspace:GetPartBoundsInBox(Char.HumanoidRootPart.CFrame * CFrame.new(0,0,-2.3),Vector3.new(5.5,5,5),Params)) do
- if Value.Parent:FindFirstChild("Humanoid") then
- InArea = true;
- EnemyCharacter = Value.Parent
- EnemyPlayer = game.Players:GetPlayerFromCharacter(EnemyCharacter)
- return InArea, EnemyCharacter, EnemyPlayer
- else
- InArea = nil;
- EnemyCharacter = nil;
- EnemyPlayer = nil;
- return InArea, EnemyCharacter, EnemyPlayer
- end
- end
- end
- local function changeSpeed(Humanoid: Humanoid,WK: number, JP: number) -- Changes Speed of character
- Humanoid.WalkSpeed = WK;
- Humanoid.JumpPower = JP;
- end
- local function ApplyParticle(InArea: boolean, EneChar: Model) -- Applys the Particle and Animation and Knockback
- if not InArea then return end
- if Combo == 5 then
- local EffectVelocity = Instance.new("BodyVelocity", EneChar:WaitForChild("HumanoidRootPart"))
- EffectVelocity.MaxForce = Vector3.new(1, 1, 1) * 1000000;
- EffectVelocity.Velocity = Vector3.new(1, 1, 1) * Char:WaitForChild("HumanoidRootPart").CFrame.LookVector * math.random(60, 120)
- Debris:AddItem(EffectVelocity, Gwait)
- end
- local particEffect = game.ServerStorage.Effects.HitEffect.Attachment:Clone()
- particEffect.Parent = EneChar:WaitForChild("HumanoidRootPart")
- EneChar:WaitForChild("Humanoid"):LoadAnimation(RS.HitStun):Play()
- Debris:AddItem(particEffect,Gwait + .1)
- end
- --@Override TakeDamage Function()
- local function TakeDamage(InArea: boolean, EnemyCharacter: Model)
- if not InArea then return end
- if Combo == 5 then EnemyCharacter:WaitForChild("Humanoid"):TakeDamage(DMG + extraDMG); return end
- EnemyCharacter:WaitForChild("Humanoid"):TakeDamage(DMG)
- end
- local function comboCheck(InArea: boolean, EneChar: Model, EnePla: Player) -- Resets combo if they take too long too punch and plays animations.
- if Combo == 0 then return end
- if changeDebounce then return end
- changeDebounce = true
- changeSpeed(Char.Humanoid, 8, 25)
- if EneChar then
- EneChar:WaitForChild("IsPunched").Value = true;
- changeSpeed(EneChar.Humanoid, 4, 10)
- end
- if Main then Main:Disconnect(); Main = nil end
- local Start = tick()
- local mainAnim = {
- RS.Animations.Hit1;
- RS.Animations.Hit2;
- RS.Animations.Hit3;
- RS.Animations.Hit4;
- RS.Animations.Hit5
- }
- local Hit = Humanoid:LoadAnimation(mainAnim[Combo]):Play()
- ApplyParticle(InArea,EneChar)
- TakeDamage(InArea,EneChar)
- if Combo == 5 then
- changeSpeed(Char.Humanoid,16,50)
- if EneChar then
- task.wait(.3)
- EneChar:WaitForChild("IsPunched").Value = false;
- changeSpeed(EneChar.Humanoid, 16, 50)
- end
- task.wait(Fwait)
- Combo = 0;
- else
- task.wait(Gwait)
- end
- Main = RunService.Heartbeat:Connect(function()
- if tick() - Start >= resetWait then
- Main:Disconnect()
- Main = nil
- Combo = 0;
- if EneChar then EneChar:WaitForChild("IsPunched").Value = false end
- else
- if EneChar then EneChar:WaitForChild("IsPunched").Value = true end
- end
- end)
- changeSpeed(Char.Humanoid, 16, 50)
- if EneChar then
- changeSpeed(EneChar.Humanoid, 16, 50)
- end
- changeDebounce = nil
- end
- --Char.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
- -- local InArea,EnemyCharacter = findPlayerFixBox();
- -- if not InArea then return end
- -- if Combo >= 4 then
- -- Char:WaitForChild("IsPunched").Value = false;
- -- end
- --end)
- Tool.Activated:Connect(function(Humano :Humanoid)
- if Char:WaitForChild("IsPunched").Value then return end
- if Debounce then return end
- Debounce = true
- if not Combo then Combo = 0; end
- local InArea,EnemyCharacter = findPlayerFixBox();
- Combo += 1;
- comboCheck(InArea, EnemyCharacter)
- Debounce = nil
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement