I messed up and dont know how to fix this

So basically i want a stamina bar, ive made the running and stamina code and thats all complete but its the ui that i messed up, this just makes it become smaller istead of being a bar that lessen and i dont how to fix

-- Services --
local players = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
-- Player Stuff --
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")


char:getAttributeChangedSignal("Stamina"):Connect(function()
	script.Parent:TweenSize(
		
		UDim2.new(1,0,char:GetAttribute("Stamina")/char:GetAttribute("StaminaMax"),0),
		"Out",
		"Quint",
		1,
		true
	)
	
end)

UDim2 is defined as UDim2.new(xScale : number,xOffset : number,yScale : number,yOffset : number)

You want to change the X scale so that it shrinks from right to left, and not up and down like you have in your existing code. In your code, just swap the one and the char:GetAttribute("Stamina")/char:GetAttribute("StaminaMax")

2 Likes

do you mind pin pointing me towards where my value placement should be?

okay i got it to work but now both of the sides are going down not just one

Hi, @demogelo11.

You’re changing Yscale instead Xscale, You might use TweenService to play tween gui instead of gui playing a tween, because GuiObject's as such TweenPosition,TweenSize, TweenSizeAndPosition is deprecated in favor of using TweenService

-- Services --
local players = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
-- Player Stuff --
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

-- might use TweenService here, not just getting it
char:getAttributeChangedSignal("Stamina"):Connect(function()
script.Parent:TweenSize(UDim2.new(char:GetAttribute("Stamina")/char:GetAttribute("StaminaMax"),0,1,0),"Out","Quint",1,true)
end)

doesnt really work still, like i said with the other guy the bar doesnt get smaller on one side both of the sides get smaller until they reach the middle which i dont want

What’s properties on bar gui ?

if AnchorPoint to 0.5,0.5 then that is problem
all what have you done is decreased it’s Position when it’s Size decreased (if Keeping AnchorPoint to 0.5,0.5) or if you want alternative then set AnchorPoint 0,0 (Yvalue can be changed)

thank you!!!

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