#Best method for a stamina system?
3 messages · Page 1 of 1 (latest)
I'm not worried about bars or GUI's I just need to know what method to use for deducting stamina from a total, I already have the run function implemented
--// Services
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
--// Character
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local plrgui = plr.PlayerGui
--// Cam Tweening
local info = TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
local tweenout = TweenService:Create(workspace.CurrentCamera, info, {FieldOfView = 75})
local tweenin = TweenService:Create(workspace.CurrentCamera, info, {FieldOfView = 70})
--// Variables
local speedhi = 18
local speedlo = 12
--// Function
local function SprintRequest(input, _gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = speedhi
tweenout:Play()
end
end
local function SprintEnd(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = speedlo
tweenin:Play()
end
end
UserInputService.InputBegan:Connect(SprintRequest)
UserInputService.InputEnded:Connect(SprintEnd)