(Note: game is filtered enabled) (Note: I'm getting an error saying I can't compare a number with user data) (Note: the stamina bar isn't tweening in size)
LOCALSCRIPT INSIDE THE GUI
-- Variables local replicatedStorage = game:GetService("ReplicatedStorage") local sprintEvent = replicatedStorage:WaitForChild("sprintEvent") local sprintEnded = replicatedStorage:WaitForChild("sprintEnded") local userInput = game:GetService("UserInputService") local plr = game.Players.LocalPlayer repeat wait() until plr.Character local humanoid = plr.Character:WaitForChild("Humanoid") local staminaFolder = plr:WaitForChild("stamFolder") local stamina = staminaFolder:WaitForChild("stamina") local staminaBar = script.Parent.background.staminabar local staminaGui = script.Parent local isSprinting = false local canSprint = true -- Scripting userInput.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.LeftShift then isSprinting = true sprintEvent:FireServer() while isSprinting and stamina.Value > 0 do staminaBar:TweenSize(UDim2.new(stamina.Value * 0.01, 0, 1, 0), "Out", "Sine", .5) stamina.Value = stamina.Value - 1 wait(.2) end if humanoid.WalkSpeed == 16 then isSprinting = false end end end) userInput.InputEnded:Connect(function(input) if input.KeyCode == Enum.KeyCode.LeftShift then isSprinting = false sprintEnded:FireServer() while isSprinting and stamina.Value < 100 do stamina.Value = stamina.Value + 1 staminaBar:TweenSize(UDim2.new(stamina.Value * 0.01, 0, 1, 0), "Out", "Sine", .5) end if stamina.Value >= 33 then canSprint = true elseif stamina.Value == 0 then canSprint = false end end end)
SCRIPT INSIDE SERVERSCRIPTSTORAGE
-- Scripting game.Players.PlayerAdded:Connect(function(player) local stamFolder = Instance.new("Folder", player) stamFolder.Name = "stamFolder" local stamina = Instance.new("IntValue", stamFolder) stamina.Name = "stamina" stamina.Value = 100 end)
Here's a photo of the hierarchy, https://i.imgur.com/a80eGgE.png
With the TweenSize function you need to use the Enum data types Roblox provides. Instead of your function call looking like this:
staminaBar:TweenSize(UDim2.new(stamina.Value * 0.01, 0, 1, 0), "Out", "Sine", .5)
It should look like this:
staminaBar:TweenSize(UDim2.new(stamina.Value * 0.01, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .5)