local StaminaManager = require(script.Parent:WaitForChild("StaminaModule")) local…
- User
local StaminaManager = require(script.Parent:WaitForChild("StaminaModule"))
local defaultSpeed = 16 local sprintSpeed = 22 local normalFov = 70 local sprintFov = 80 local crouchFov = 65 local crouchSpeed = 8 local staminaDrainRate = 17
local Settings = { Lifetime = 0.15, DashVelocity = 55, Cooldown = 3, DashStaminaCost = 20, JumpCooldown = 1.1 }
local Services = setmetatable({}, { __index = function(Self, Index) local NewService = game:GetService(Index) if NewService then Self[Index] = NewService end return NewService end })
local UserInputService = Services.UserInputService local TweenService = Services.TweenService local RunService = Services.RunService local Players = Services.Players local ReplicatedStorage = Services.ReplicatedStorage
local sprintKey = Enum.KeyCode.LeftShift local crouchKey = Enum.KeyCode.C local Player = Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") local Camera = workspace.CurrentCamera local healthBar = Player:WaitForChild("PlayerGui"):WaitForChild("StaminaAndHealthBar"):WaitForChild("Frame"):WaitForChild("HealthBar"):WaitForChild("Bar") local staminaBar = Player:WaitForChild("PlayerGui"):WaitForChild("StaminaAndHealthBar"):WaitForChild("Frame"):WaitForChild("StaminaBar"):WaitForChild("Bar")
local sprintAnim = ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Player"):WaitForChild("SprintAnim") local animTrack = Humanoid:LoadAnimation(sprintAnim) local movementKeys = {Enum.KeyCode.W, Enum.KeyCode.A, Enum.KeyCode.S, Enum.KeyCode.D} local movementKeysPressed = {} local shiftPressed, sprinting, isCrouching, isMoving, isSliding = false, false, false, false, false local canJump = true
local Animations = { Forward = Humanoid:LoadAnimation(ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Player"):WaitForChild("FrontDash")), Backward = Humanoid:LoadAnimation(ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Player"):WaitForChild("BackDash")), Left = Humanoid:LoadAnimation(ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Player"):WaitForChild("LeftDash")), Right = Humanoid:LoadAnimation(ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Player"):WaitForChild("RightDash")), } local BV = Instance.new("BodyVelocity")
local function tweenFov(duration, fov) local tween = TweenService:Create(Camera, TweenInfo.new(duration, Enum.EasingStyle.Quad), { FieldOfView = fov }) tween:Play() tween.Completed:Wait() tween:Destroy() end
local function updateStaminaBar() local stamina = StaminaManager.GetStamina() local tween = TweenService:Create(staminaBar, TweenInfo.new(0.25, Enum.EasingStyle.Quad), { Size = UDim2.new(stamina / StaminaManager.maxStamina, 0, 1, 0) }) tween:Play() end
local function startSprinting() if not sprinting and StaminaManager.GetStamina() > 0 and not isCrouching then sprinting = true StaminaManager.ReduceStamina(staminaDrainRate * RunService.RenderStepped:Wait()) Humanoid.WalkSpeed = sprintSpeed if Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then animTrack:Play() end tweenFov(0.25, sprintFov) updateStaminaBar() end end
- Assistant