Hello, I am having a problem with my stamina UI, I am not a scripter or a UI designer so I have no idea what cost this problem.
- What do you want to achieve? Keep it simple and clear!
A sprinting system with a stamina bar
- What is the issue? Include screenshots / videos if possible!
The issue is that the stamina bar is not working properly, when I press the button to start sprinting the stamina bar started to become weird. Here’s a video of the issue
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes I did but I still have no idea how to fix it. I do not know if it’s a UI problem or a script problem.
Here’s the script (Keep in mind that I am not a scripter, I used an open source script I found which I understand some of the code)
local UIS = game:GetService('UserInputService')
local Frame1 = script.Parent:WaitForChild('Frame1'):WaitForChild('Frame2')
local player = game.Players.LocalPlayer
local NormalWalkSpeed = 16
local NewWalkSpeed = 100
local ii = 10
local running = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character
UIS.InputBegan:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.Q and gameProcessed == false then
character.Humanoid.WalkSpeed = NewWalkSpeed
running = true
while ii > 0 and running do
ii = ii - 0.5
Frame1:TweenSize(UDim2.new(ii / 10, 5, 1, 0), 'Out', 'Quint', .1, true)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)
UIS.InputEnded:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.Q and gameProcessed == false then
character.Humanoid.WalkSpeed = NormalWalkSpeed
running = false
while ii < 10 and not running do
ii = ii + 0.1
Frame1:TweenSize(UDim2.new(ii / 10, 5, 1, 0), 'Out', 'Quint', .1, true)
wait()
if ii <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)