0 views0 copies0 likes

Sprint Stamina Meter for Obby Courses

Universal script

Copy it, then test it in your own Studio place.

Combat & movement Verified

Script code

30 lines ยท 1.3 KB
Download
local Players = game:GetService("Players")local RunService = game:GetService("RunService")local Input = game:GetService("UserInputService")local player = Players.LocalPlayerlocal meter = Instance.new("ScreenGui")meter.ResetOnSpawn = falsemeter.Parent = player:WaitForChild("PlayerGui")local track = Instance.new("Frame")track.Position = UDim2.fromOffset(18, 75)track.Size = UDim2.fromOffset(184, 12)track.BackgroundColor3 = Color3.fromRGB(38, 42, 59)track.Parent = meterlocal fill = Instance.new("Frame")fill.BackgroundColor3 = Color3.fromRGB(255, 171, 45)-- โ€ฆopen Get script for the full source

About this script

Add this LocalScript to StarterPlayerScripts in your obby. Holding Left Shift boosts movement and drains the visible stamina bar while the avatar is moving. Releasing Shift restores stamina, and running out forces a pause before boost can start again. The local example fits solo courses and prototypes. Keep race rewards on the server and test low-stamina recovery after a character reset.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Input = game:GetService("UserInputService")
local player = Players.LocalPlayer
local meter = Instance.new("ScreenGui")
meter.ResetOnSpawn = false
meter.Parent = player:WaitForChild("PlayerGui")
local track = Instance.new("Frame")
track.Position = UDim2.fromOffset(18, 75)
track.Size = UDim2.fromOffset(184, 12)
track.BackgroundColor3 = Color3.fromRGB(38, 42, 59)
track.Parent = meter
local fill = Instance.new("Frame")
fill.BackgroundColor3 = Color3.fromRGB(255, 171, 45)
fill.Parent = track
local stamina, exhausted = 1, false
player.CharacterAdded:Connect(function() stamina, exhausted = 1, false end)

RunService.Heartbeat:Connect(function(dt)
	local humanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
	if not humanoid or humanoid.Health <= 0 then return end
	local moving = humanoid.MoveDirection.Magnitude > 0
	local held = Input:IsKeyDown(Enum.KeyCode.LeftShift)
	local boosting = moving and held and not exhausted
	stamina = math.clamp(stamina + dt * (boosting and -0.36 or 0.22), 0, 1)
	if stamina == 0 then exhausted = true end
	if not held and stamina >= 0.25 then exhausted = false end
	humanoid.WalkSpeed = boosting and stamina > 0 and 24 or 16
	fill.Size = UDim2.fromScale(stamina, 1)
end)