What do you want to achieve? I want make a stamina bar which tween on both sides. Example, mostly stamina has one side to decrease or to increase but instead I want do both side to decrease or to increase. also when when on low will turn to red. Also will appear when use shift. but if dont use shift then stamina bar wont appear.
What is the issue? stamina bar only decrease on one side. wont change to red when on low. also I dont know how to make stamina to show up when use shift.
What solutions have you tried so far? I been search tutorials and non of these is match what I look for. Mostly, these is only show stamina bar decrease on one side and not show how make change color or show up when use shift.
!!REMINDER!! I’m beginner, I dont know lot about script field. so Im completely lack in these.
i have a script just like this! its really easy if you use gui! ill get the script for you, best part: it does not use tween! its lag free and compact to use!
local display = script.Parent
local head = script.Parent.Parent:WaitForChild("Head")
local label = display.BillboardGui.HEALTH
local frame = display.BillboardGui.bg.Frame
local Hum = script.Parent.Parent:WaitForChild("Humanoid")
Hum.HealthChanged:Connect(function()
label.Text = Hum.Health
local tmp = (Hum.Health / Hum.MaxHealth * 200)
frame.Size = UDim2.new(0, tmp, 0, 50)
frame.Position = UDim2.new(0, 100 - (tmp / 2), 0, 0)
end)
if you need anything related to this just ask! if you want me to personally install this just reply! (costs 5 robux bc i have other work to do)
Okay, so you will be needing a stamina bar ui for this script. With a “bar frame object”
Here’s the script I made for it, hope it helps:
local Ui = script.Parent
local MAX_STAMINA = 100
local CURRENT_STAMINA = MAX_STAMINA
local Uis = game:GetService("UserInputService")
local IsRunning = false
local Bar --Path to the bar
if not game:IsLoaded() then repeat task.wait() until game:IsLoaded() end
Uis.InputBegan:Connect(function()
if Uis:IsKeyDown(Enum.KeyCode.LeftShift) then
if CURRENT_STAMINA == 0 then return end
IsRunning = true
while IsRunning do
task.wait(.25)
CURRENT_STAMINA -= 1
math.clamp(CURRENT_STAMINA, 0, MAX_STAMINA)
if CURRENT_STAMINA == 0 then
IsRunning = false
return
end
end
end
end)
Uis.InputEnded:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
IsRunning = false
while not IsRunning do
task.wait()
if CURRENT_STAMINA < MAX_STAMINA then
task.wait(.25)
CURRENT_STAMINA += 1
math.clamp(CURRENT_STAMINA, 0, MAX_STAMINA)
if CURRENT_STAMINA == MAX_STAMINA then
return
end
end
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function(dt)
Bar.Size = UDim2.new(0,CURRENT_STAMINA * (374/MAX_STAMINA),0,46) --374 was the max size of the bar I took replace it with your bar size and 46 same but for the (yOffset)
end)
its truly amazing model, however if keep hold shift to 0 then auto regen it. which I dont want that. I only want to regen is by release shift then will regen.
thanks i guess, I know mine is for a healthbar but I think personally that doesnt matter as much, the code still used gui and a script that was easily changable with one good look. still thanks… i guess?