Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UIS = game:GetService("UserInputService")
- local RS = game:GetService("ReplicatedStorage")
- local TS = game:GetService("TweenService")
- local rs = game:GetService('RunService')
- local GUIS = game:GetService("GuiService")
- local Folder = RS.Combat
- local Animate = Folder.Animate
- local Block = Folder.Block
- local CreateHitbox = Folder.CreateHitbox
- local Player = game:GetService("Players").LocalPlayer
- local PlayerGui = Player.PlayerGui
- local Hud = PlayerGui:FindFirstChild("HUD")
- local HudMain = Hud:FindFirstChild("Main")
- local HudPower = HudMain:FindFirstChild("Power")
- local HudHealth = HudMain:FindFirstChild("Health")
- local HudStamina = HudMain:FindFirstChild("Stamina")
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid = Character:FindFirstChildOfClass("Humanoid")
- local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
- local VectorForce = HumanoidRootPart:FindFirstChild("VectorForce")
- local Animations = Character:WaitForChild("Animations")
- local Config = require(Character:WaitForChild("PlayerConfig"))
- local Camera = game.Workspace.CurrentCamera
- local isReady = Config.isReady
- local isBlocking = Config.isBlocking
- local isAttacking = Config.isAttacking
- local currentSequence = Config.currentSequence
- local lastAttackTick = Config.lastAttackTick
- local lastBlockCooldownTick = Config.lastBlockCooldownTick
- local lastSlideTick = Config.lastSlideTick
- local lastDodgeTick = Config.lastDodgeTick
- local lshift = Config.lshift
- local q = Config.a
- local e = Config.d
- local isSliding = Config.isSliding
- local isJumping = Config.isJumping
- local isFalling = Config.isFalling
- local isStanding = Config.isStanding
- local isDodging = Config.isDodging
- --00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00
- local easingtime = 0.1 --0~1, lower = smoother and slower
- local walkspeeds = Config.walkspeeds
- local attackSequence = {
- Animations.fistpunch1,
- Animations.fistpunch2,
- Animations.fistpunch3,
- Animations.fistpunch4
- }
- local Idle = Animations.fistidle
- local Block = Animations.fistblock
- local Slide = Animations.slide
- local DodgeLeft = Animations.dodgeleft
- local DodgeRight = Animations.dodgeright
- --00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00
- function roundNumber(num, numDecimalPlaces)
- return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
- end
- function lerp(a, b, t)
- return a * (1-t) + (b*t)
- end
- function shiftLock(active) --Toggle shift.lock function
- if active then
- Config.AutoRotate = false
- Humanoid.AutoRotate = Config.AutoRotate
- rs:UnbindFromRenderStep("ShiftLockCamera")
- rs:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
- UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
- Humanoid.CameraOffset = Vector3.new(lerp(Humanoid.CameraOffset.X, 1.75, .05),0,0)
- Camera.FieldOfView = lerp(Camera.FieldOfView, 60,0.05)
- local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ()
- HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0,y,0),.2)
- end)
- else
- rs:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
- rs:BindToRenderStep("ShiftLockCamera", Enum.RenderPriority.Camera.Value, function()
- Humanoid.CameraOffset = Vector3.new(lerp(Humanoid.CameraOffset.X, 0, .05),0,0) --Move the camera back to normal.
- Camera.FieldOfView = lerp(Camera.FieldOfView, 70,0.05)
- end)
- Humanoid.Changed:Connect(function(CameraOffset)
- local found = false
- if Humanoid.CameraOffset.X == 0 and not found then
- found = true
- rs:UnbindFromRenderStep("ShiftLockCamera")
- Humanoid.CameraOffset = Vector3.new(0,0,0)
- end
- end)
- UIS.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
- Config.AutoRotate = true
- Humanoid.AutoRotate = Config.AutoRotate
- end
- end
- shiftLock(false)
- GUIS.MenuOpened:Connect(function()
- shiftLock(false)
- end)
- GUIS.MenuClosed:Connect(function()
- if isReady then
- shiftLock(true)
- end
- end)
- --00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00
- local function checkState()
- if Humanoid:GetState() == Enum.HumanoidStateType.Jumping then
- isJumping = true
- isFalling = false
- isStanding = false
- elseif Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
- isJumping = false
- isFalling = true
- isStanding = false
- else
- isJumping = false
- isFalling = false
- isStanding = true
- end
- end
- Humanoid.StateChanged:Connect(checkState)
- --00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00
- -- Animate:FireServer(animationObj, animationSpeed, isRunning)
- connectionBegan = UIS.InputBegan:Connect(function(input, gameProcessed)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- --ReadyStance
- if input.KeyCode == Config.MeleeActivationKey then
- if (tick() - Config.lastActivation) > Config.ActivationSpeed then
- if not isReady then
- isReady = true
- shiftLock(true)
- Animate:FireServer(Idle, 1, true)
- Config.lastActivation = tick()
- else
- Animate:FireServer(Idle, 1, false)
- shiftLock(false)
- --rs:UnbindFromRenderStep("ShiftLockCamera")
- isReady = false
- isBlocking = false
- isSliding = false
- Config.lastActivation = tick()
- end
- end
- end
- -- Left Shift
- if input.KeyCode == Enum.KeyCode.LeftShift then
- lshift = true
- end
- --Dodge Left/ Q
- if input.KeyCode == Enum.KeyCode.Q then
- q = true
- if not isBlocking and isReady then
- if (tick() - lastDodgeTick) > Config.DodgeSpeed then
- isDodging = true
- Animate:FireServer(DodgeLeft,1,true)
- lastDodgeTick = tick()
- end
- end
- end
- --Dodge Right/ E
- if input.KeyCode == Enum.KeyCode.E then
- e = true
- if not isBlocking and isReady then
- if (tick() - lastDodgeTick) > Config.DodgeSpeed then
- isDodging = true
- Animate:FireServer(DodgeRight,1,true)
- lastDodgeTick = tick()
- end
- end
- end
- -- slide
- if input.KeyCode == Enum.KeyCode.LeftControl then
- if not isBlocking and not isAttacking and not isSliding then
- if (tick() - lastSlideTick) > Config.SlideSpeed then
- isSliding = true
- Animate:FireServer(Slide, 1, true)
- lastSlideTick = tick()
- end
- end
- end
- end
- --Attacking
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if isReady and not isAttacking and not isBlocking and not isSliding then
- if (tick() - lastAttackTick) > Config.AttackSpeed then
- isAttacking = true
- currentSequence = currentSequence + 1
- if currentSequence >= (#attackSequence + 1) then
- currentSequence = 1
- end
- Animate:FireServer(attackSequence[currentSequence], 2, true)
- CreateHitbox:FireServer(attackSequence[currentSequence],0.1)
- print(currentSequence)
- end
- end
- end
- --Blocking
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- if isReady and not isBlocking and not isAttacking and not isSliding then
- if (tick() - lastBlockCooldownTick) > Config.BlockSpeed then
- isBlocking = true
- Animate:FireServer(Block, 2, true)
- end
- end
- end
- end)
- --00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00
- connectionEnded = UIS.InputEnded:Connect(function(input, gameProcessed)
- -- Stopped Blocking
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- if isReady and isBlocking then
- Animate:FireServer(Block, 1, false)
- Animate:FireServer(Idle, 1, true)
- lastBlockCooldownTick = tick()
- isBlocking = false
- end
- end
- -- Stopped Attacking
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if isReady and isAttacking then
- lastAttackTick = tick()
- isAttacking = false
- end
- end
- -- Stopped Sprinting
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.LeftShift then
- lshift = false
- end
- end
- -- Stopped Sliding
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.LeftControl then
- isSliding = false
- Animate:FireServer(Slide, 1, false)
- if not isBlocking and isReady then
- Animate:FireServer(Idle, 1, true)
- end
- end
- end
- -- Stopped Dodge Left
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.Q then
- q = false
- Animate:FireServer(DodgeLeft, 1, false)
- if not isBlocking and isReady then
- Animate:FireServer(Idle, 1, true)
- end
- end
- end
- -- Stopped Dodge Right
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.E then
- e = false
- Animate:FireServer(DodgeRight, 1, false)
- if not isBlocking and isReady then
- Animate:FireServer(Idle, 1, true)
- end
- end
- end
- end)
- --00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00--00
- rs:BindToRenderStep("Movement", Enum.RenderPriority.Character.Value, function()
- if Character and HumanoidRootPart and Humanoid and Humanoid.Health > 0 then
- HudStamina.Size = UDim2.new( (Humanoid.MaxHealth/Humanoid.Health) *0.25, 0,0.01,0 )
- local HumanoidRootPartSpeed = roundNumber(HumanoidRootPart.Velocity.magnitude,1)
- --[[ FOR FIRST PERSON
- local inFirstPerson = (Camera.CoordinateFrame.p - Character.Head.Position).Magnitude
- if inFirstPerson < .51 then
- for _, v in pairs(Character:GetChildren())do
- if v:IsA"Part" and v.Name ~= "Head" and v.Name ~= "Torso" then
- v.LocalTransparencyModifier = 0
- end
- end
- --Humanoid.CameraOffset = Vector3.new(0,0,0)
- end]]
- -- Running and Sliding
- if lshift and not isSliding then
- Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed,Humanoid.WalkSpeed + (walkspeeds.runningspeed - Humanoid.WalkSpeed),easingtime)
- elseif not isSliding then
- Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed,Humanoid.WalkSpeed + (walkspeeds.walkingspeed - Humanoid.WalkSpeed),easingtime)
- elseif isSliding then
- Humanoid.WalkSpeed = 0
- end
- if isFalling then
- VectorForce.Force = Vector3.new(0,0,-( (HumanoidRootPartSpeed * 4)/2 ))
- elseif isJumping then
- VectorForce.Force = Vector3.new(0,0,-( (HumanoidRootPartSpeed * 7)/3 ))
- elseif isStanding then
- VectorForce.Force = Vector3.new(0,0,-( (HumanoidRootPartSpeed * 2)/3 ))
- end
- else
- rs:UnbindFromRenderStep("Movement")
- return warn(Character.Name.. " died")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement