How I fix this tween?

How do I make this tween properly? When the script is runned it only tweens a bit.

local staminaBar = script.Parent
local stamina = RPS:WaitForChild("LocalVariables"):WaitForChild("stamina")
local maxStamina = 20
local sprinting = false

local function updateBar()
	local percent = (((stamina.Value / maxStamina) * 100) / 100 )
	print(percent)
	staminaBar:TweenSize(UDim2.new(percent,0,1,0))
	print(staminaBar.Size)
end

The value of (((stamina.Value / maxStamina) * 100) / 100 ) could just be inherently small and it might not look like its tweening properly (and besides *100/100 isn’t necessary as both of them cancel out which equals stamina.Value / maxStamina)

Why are you multiplying it by 100 just to divide by 100?
You attempted to make sort of rounding?

I recomend making stamina as an attribute for humanoid (optional)

local staminaBar = script.Parent
local stamina = RPS:WaitForChild("LocalVariables"):WaitForChild("stamina")
local maxStamina = 20
local sprinting = false
local TweenService = game:GetService("TweenService")

local TweenInfo = TweenInfo.new(0.25)

local function updateBar():()
	local percent:number = stamina.Value / maxStamina
	TweenService:Create(staminaBar,TweenInfo,{Size = UDim2.fromScale(percent,1)}):Play()
end

BTW use service autocompletion plugin or smth if you are lazy to write full name of service: https://create.roblox.com/store/asset/11380642657

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.