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)
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")
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
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)