Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RepStorage = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local InputService = game:GetService("UserInputService")
- local Players = game:GetService("Players")
- local Lighting = game:GetService("Lighting")
- local Debris = game:GetService("Debris")
- local RepModules = RepStorage:WaitForChild("Modules")
- local Data = RepModules:WaitForChild("Data")
- local HitboxModule = require(RepModules:WaitForChild("HitboxModule"))
- local CameraShake = require(RepModules:WaitForChild("CameraShaker"))
- local PlayerData = require(Data:WaitForChild("PlayerData"))
- local Plr = Players:GetPlayerFromCharacter(script.Parent)
- local PlrGui = Plr:WaitForChild("PlayerGui")
- local Char = Plr.Character
- local Hum = Char:WaitForChild("Humanoid")
- local HumRP = Char:WaitForChild("HumanoidRootPart")
- local Animator = Hum:WaitForChild("Animator")
- local Cam = workspace.CurrentCamera
- local ClientFunctions = {}
- local Anims = RepStorage:WaitForChild("Animations")
- local Events = RepStorage:WaitForChild("Events")
- local DataIndex = PlayerData.Stats
- local DashValue = false
- local LockOnValue = false
- local InventoryValue = false
- local RunTrack = Animator:LoadAnimation(Anims:WaitForChild("Running"))
- local BlockTrack = Animator:LoadAnimation(Anims:WaitForChild("Blocking"))
- function ClientFunctions:Run(Status)
- local SPEED_UP = 78
- local SLOW_DOWN = 70
- local TWEEN_SPEED = .6
- local WALK_SPEED = DataIndex[Char:GetAttribute("Type")].WalkSpeed
- local RUN_SPEED = DataIndex[Char:GetAttribute("Type")].RunSpeed
- local ANIM_SPEED = DataIndex[Char:GetAttribute("Type")].RunAnimationSpeed
- if Status then
- if Char:GetAttribute("Running") or Char:GetAttribute("Attacking") or Char:GetAttribute("Blocking") or Char:GetAttribute("MechanicDisable") then
- return
- end
- RunTrack:Play()
- RunTrack:AdjustSpeed(ANIM_SPEED)
- Hum.WalkSpeed = RUN_SPEED
- Char:SetAttribute("Running", true)
- else
- RunTrack:Stop()
- Hum.WalkSpeed = WALK_SPEED
- Char:SetAttribute("Running", false)
- end
- end
- function ClientFunctions:Block(Status)
- local BLOCK_SPEED = 4
- if Status then
- if Char:GetAttribute("Attacking") or Char:GetAttribute("Dashing") or Char:GetAttribute("Blocking") or Char:GetAttribute("MechanicDisable") then
- return
- end
- self:Run(false)
- BlockTrack:Play()
- Char:SetAttribute("Blocking", true)
- Hum.WalkSpeed = BLOCK_SPEED
- else
- BlockTrack:Stop()
- Char:SetAttribute("Blocking", false)
- Hum.WalkSpeed = DataIndex[Char:GetAttribute("Type")].WalkSpeed
- end
- end
- function ClientFunctions:Dash()
- if Char:GetAttribute("Attacking") or Char:GetAttribute("Blocking") or Char:GetAttribute("Dashing") or Char:GetAttribute("MechanicDisable") --[[or ShiftLock ~= Enum.MouseBehavior.LockCenter]] then
- return
- end
- local VELOCITY_FORCE = 30
- local VELOCITY_DESPAWN = .4
- local VELOCITY_DELAY = .1
- local DASH_COOLDOWN = 2.25
- local ANIMATION_SPEED = 2
- local Direction
- local Connection
- local Keys = {Forward = Enum.KeyCode.W, Backward = Enum.KeyCode.S, Left = Enum.KeyCode.A, Right = Enum.KeyCode.D}
- for MovementDirection, MovementKey in pairs(Keys) do
- if InputService:IsKeyDown(MovementKey) then
- Direction = MovementDirection
- elseif Hum.MoveDirection.Magnitude == 0 then
- return
- end
- end
- local DashAnim = Anims:WaitForChild("Dash"..Direction)
- local DashSound = HumRP:WaitForChild("Dash")
- local DashTrack = Animator:LoadAnimation(DashAnim)
- DashTrack.Priority = Enum.AnimationPriority.Action
- local DashForce = Instance.new("BodyVelocity")
- DashForce.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- Hum.JumpPower = 0
- DashSound:Play()
- DashTrack:Play()
- DashTrack:AdjustSpeed(ANIMATION_SPEED)
- Char:SetAttribute("Dashing", true)
- task.wait(VELOCITY_DELAY)
- DashForce.Parent = HumRP
- Debris:AddItem(DashForce, VELOCITY_DESPAWN)
- Connection = RunService.RenderStepped:Connect(function()
- DashForce.Velocity = Hum.MoveDirection * VELOCITY_FORCE
- end)
- task.delay(DASH_COOLDOWN, function()
- Char:SetAttribute("Dashing", false)
- Hum.JumpPower = DataIndex[Char:GetAttribute("Type")].JumpPower
- Connection:Disconnect()
- end)
- end
- function ClientFunctions:CombatStatement(Click, Range, ShiftLock)
- if Char:GetAttribute("Attacking") or Char:GetAttribute("Blocking") or Char:GetAttribute("Sliding") then
- return
- end
- local RayInstance, RayBool = HitboxModule:Raycast(Char, Range, true)
- local Enemy
- if RayBool then
- Enemy = HitboxModule:Magnitude(Char, Range)
- end
- Events:WaitForChild("Combat"):FireServer(Enemy, Click)
- end
- function ClientFunctions:Inventory()
- -- Due a rewrite.
- local InventoryGui = PlrGui:WaitForChild("InventoryGui")
- local ImageLabel = InventoryGui:WaitForChild("ImageLabel")
- local VPF = ImageLabel:WaitForChild("ViewportFrame")
- local Blur = Lighting:WaitForChild("Blur")
- local Clone
- local HoldInDisplay
- local MouseInDisplay
- local function CallbackOn(State)
- if State == Enum.TweenStatus.Canceled then
- TweenService:Create(Blur, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = 0}):Play()
- else
- InventoryGui.Enabled = true
- Blur.Enabled = true
- end
- end
- local function CallbackOff(State)
- if State == Enum.TweenStatus.Canceled then
- TweenService:Create(Blur, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = 13}):Play()
- else
- InventoryGui.Enabled = false
- Blur.Enabled = false
- end
- end
- if not InventoryValue then
- InventoryValue = true
- InventoryGui.Enabled = true
- Blur.Enabled = true
- ImageLabel:TweenPosition(UDim2.new(0.278, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1.65, true, CallbackOn)
- TweenService:Create(Blur, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = 13}):Play()
- if not VPF then
- local VPFCam = Instance.new("Camera")
- VPFCam.Parent = VPF
- VPFCam.CFrame = CFrame.new(0, 0, 0)
- VPF.CurrentCamera = VPFCam
- Char.Archivable = true
- Clone = Char:Clone()
- Clone.Parent = VPF.WorldModel
- Clone:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 0, - 7.5), Vector3.new(0, 0, 0)))
- Clone.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
- for _,Child in ipairs(Clone:GetDescendants()) do
- if Child:IsA("Script") or Child:IsA("LocalScript") or Child:IsA("Folder") then
- Child:Destroy()
- end
- end
- end
- VPF.MouseEnter:Connect(function() MouseInDisplay = true end)
- VPF.MouseLeave:Connect(function() MouseInDisplay = false end)
- else
- InventoryValue = false
- InventoryGui.ImageLabel:TweenPosition(UDim2.new(-.5, 0, 0.048, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1.65, true, CallbackOff)
- TweenService:Create(Blur, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = 0}):Play()
- end
- end
- function ClientFunctions:LockOn()
- local ENEMY_RANGE = 35
- local TWEEN_TIME = .35
- local MAGNITUDE_OFFSET = 11
- local CHARACTERS_OFFSET = Vector3.new(3, 3, 0)
- local MODIFIED_OFFSET = Vector3.new(1, 0, 1)
- local FINAL_CFRAME = Vector3.new(0, 1, 0)
- local Enemy = HitboxModule:Magnitude(Char, 35)
- local OriginalCFrame = Cam.CFrame
- if not LockOnValue then
- if not Enemy then
- print("No enemy in range")
- return
- end
- LockOnValue = true
- Cam.CameraType = Enum.CameraType.Scriptable
- task.spawn(function()
- while LockOnValue do
- local CharPos = HumRP.Position
- local EnemyPos = Enemy:WaitForChild("HumanoidRootPart").Position
- local Difference = EnemyPos + ((CharPos + CHARACTERS_OFFSET) - EnemyPos).Unit * ((CharPos - EnemyPos).Magnitude + MAGNITUDE_OFFSET)
- local NewVar = CFrame.new(Difference, EnemyPos)
- local ModEnemyPos = (CharPos - EnemyPos).Unit * MODIFIED_OFFSET
- local NewCF = CFrame.lookAt(CharPos, CharPos + ModEnemyPos, HumRP.CFrame.UpVector) * CFrame.fromAxisAngle(FINAL_CFRAME, math.pi)
- Char:SetPrimaryPartCFrame(NewCF)
- TweenService:Create(Cam, TweenInfo.new(TWEEN_TIME, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {CFrame = NewVar}):Play()
- RunService.RenderStepped:Wait()
- end
- end)
- else
- LockOnValue = false
- Cam.CameraType = Enum.CameraType.Custom
- end
- end
- function ClientFunctions:Ragdoll(Type)
- if Type then
- Hum:ChangeState(Enum.HumanoidStateType.Ragdoll)
- Hum.BreakJointsOnDeath = false
- Hum.RequiresNeck = false
- else
- Hum:ChangeState(Enum.HumanoidStateType.GettingUp)
- Hum.BreakJointsOnDeath = true
- Hum.RequiresNeck = true
- end
- end
- function ClientFunctions:CameraShake(Preset)
- local function ShakeCamera(ShakeCf)
- Cam.CFrame = Cam.CFrame * ShakeCf
- end
- local RenderPriority = Enum.RenderPriority.Camera.Value + 1
- local CamShake = CameraShake.new(RenderPriority, ShakeCamera)
- CamShake:Start()
- CamShake:Shake(CameraShake.Presets[Preset])
- end
- function ClientFunctions:ChildAdded(Child)
- if Child.Name == "CamShake" then
- ClientFunctions:CameraShake(Child.Value)
- end
- end
- return ClientFunctions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement