#stamina bar size goes out of control
46 messages · Page 1 of 1 (latest)
local staminabar = script.Parent
local staminamax = 100
local currentstamina = 100
local ts = game:GetService("TweenService")
local tsinfo = TweenInfo.new(.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local playts = ts:Create(staminabar, tsinfo, {Size = UDim2.new(currentstamina /staminamax, 0, 1, 0)})
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if uis:IsKeyDown(Enum.KeyCode.LeftShift) then
currentstamina -= 1
playts:Play()
end
end)
uis.InputEnded:Connect(function(input, gpe)
if gpe then return end
if uis:IsKeyDown(Enum.KeyCode.LeftShift) then
currentstamina += 1
playts:Play()
end
end)```
hmmm when the shift key is let go, youre playing the tween animation again which i think is whats causing it to keep goin haha
try this?
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if uis:IsKeyDown(Enum.KeyCode.LeftShift) then
currentstamina -= 1
playts:Play()
end
end)
uis.InputEnded:Connect(function(input, gpe)
if gpe then return end
if uis:IsKeyDown(Enum.KeyCode.LeftShift) then
currentstamina += 1
end
end)
lmk if this helps :D
not rlly but someone told me to use autoscale lite
** You are now Level 1! **
still doesnt work, the problem is the tweening, instead of going from right to left (maxstam to minstam) it goes from left to right but with the y axis moving upwards
oooooo okok, i think you need to change the anchor point then, if you haven't tried that??
^
@next sail hey do you still need help?
yea my bar needs a spanking
i set it to 0, 0
alr so basically
when i click shift instead of my bar going from right to left (like a basic stamina bar) it goes from LEFT to right AND the y axis has a mind of its own
bye can prob help better but i was gonna suggest 1,0 to anchor it on edge
so for Y axis im going to guess your tween is not updating correctly
yea its prolly that
you should probably move your tween creation inside of your updatestaminbar function
that way the tween can be recalculated everytime with the currentStamina value each time it changes
also did you only want it to decreaes on leftshift?
from what i see
ignore the character but my bar does that
its decreasing from any button as long as left shift is being held down
is that right?
alright wait
well when i press left shift its supposed to go down until i let go of the button
ok you should use a while loop for that
so while your key is down and the value of currentStamina > 0 it will update stamina bar
local newSize = UDim2.new(currentstamina / staminamax, 0, 1, 0)
for local new size
fuck i forgot
alr lemme add a loop thing and put this in the script and il get back to u
👍
well the bar works but the size of it is still pretty questionable, its the udim thats prolly the error but i cant seem to fix it
** You are now Level 2! **
i set a anchorpoint to 0, 0
@next sail give me a visual
the low taper ninja meme is still MAAASSSIVEEE as of right now