#stamina bar size goes out of control

46 messages · Page 1 of 1 (latest)

next sail
#

well the bar changes size atleast lol but it gets larger and longer and thats 2 things i dont want it to do, im aware the script is not well made but i just want to know why the size does that, if any1 can help please do

#

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)```
sinful hound
# next sail ```local uis = game:GetService("UserInputService") local staminabar = script.Pa...

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

next sail
#

not rlly but someone told me to use autoscale lite

nimble gladeBOT
#

studio** You are now Level 1! **studio

next sail
#

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

sinful hound
#

oooooo okok, i think you need to change the anchor point then, if you haven't tried that??

amber wedge
#

@next sail hey do you still need help?

next sail
#

yea my bar needs a spanking

amber wedge
#

could you explain your problem again

#

im a bit confused from your inital statement

next sail
next sail
#

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

sinful hound
#

bye can prob help better but i was gonna suggest 1,0 to anchor it on edge

amber wedge
#

so for Y axis im going to guess your tween is not updating correctly

amber wedge
#

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?

amber wedge
#

from what i see

next sail
#

ignore the character but my bar does that

amber wedge
#

its decreasing from any button as long as left shift is being held down

#

is that right?

next sail
#

alright wait

next sail
amber wedge
#

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

next sail
amber wedge
#

does that clarify on your issue?

next sail
next sail
#

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

nimble gladeBOT
#

studio** You are now Level 2! **studio

next sail
#

i set a anchorpoint to 0, 0

amber wedge
#

@next sail give me a visual

next sail
#

alr lemem take a vid rq

#

see how its big and greedy

next sail
#

the low taper ninja meme is still MAAASSSIVEEE as of right now