local stm = script.Parent
local stmvalue = script.Parent.Stamina
local stmvalue2 = script.Parent.MaxStamina
stm.Changed:Connect(function()
stm:TweenSize(UDim2.new(stmvalue/stmvalue2 * .2,0,0.02,1),“In”,“Linear”,1)
end)
So I am trying to get this to work with two number values in the gui stamina and max stamina both being 100 so if they ever change in value it still works, it dosent move at all it could be a problem with my math I do not know.
1 Like
I noticed flaws in the code and updated it to this
local stm = script.Parent
local stmvalue = script.Parent.Stamina.Value
local stmvalue2 = script.Parent.MaxStamina.Value
stmvalue.Changed:Connect(function()
stm:TweenSize(UDim2.new(stmvalue/stmvalue2 * .2,0,0.02,1),“In”,“Linear”,1)
end)
1 Like
starmaq
(starmaq)
October 19, 2019, 2:46pm
#3
Just a little question, is stm
a value object? And if so are Stamina and MaxStamina too?
1 Like
yesir they are both number values of 100
1 Like
My math is probably the problem I need it to work with any size stamina gui
1 Like
stmvalue is a number value for stamina its 100 stmvalue2 is max stamina also 100 then
stm is the thing im trying to tween
1 Like
systemac
(systemac)
October 19, 2019, 2:52pm
#7
You need to use the new value when tweening the UI. Here is what I mean:
local stm = script.Parent
local stmvalue = script.Parent.Stamina
local stmvalue2 = script.Parent.MaxStamina.Value
stmvalue.Changed:Connect(function(value)
stm:TweenSize(UDim2.new(value/stmvalue2 * .2,0,0.02,1),"In","Linear",1)
end)
2 Likes
starmaq
(starmaq)
October 19, 2019, 2:54pm
#8
Yeah, as @RetributionVI said, script.Parent.Stamina
is a reference to the object, not the value inside of it, so do script.Parent.MaxStamina.Value
and script.Parent.Stamina.Value
1 Like
in the second code i thought i did that lol but the second code i posted makes my stamina line move only one time. and its far off from what its supposed to be ill try what he said and get back to you guys.
2 Likes
ocal stm = script.Parent local stmvalue = script.Parent.Stamina local stmvalue2 = script.Parent.MaxStamina.Value stmvalue.Changed:Connect(function(value) stm:TweenSize(UDim2.new(value/stmvalue2 * .2,0,0.02,1),“In”,“Linear”,1) end)
so i put this and it did not even print
local stm = script.Parent
local stmvalue = script.Parent.Stamina
local stmvalue2 = script.Parent.MaxStamina.Value
stmvalue.Changed:Connect(function(value)
print(“I see a change”)
stm:TweenSize(UDim2.new(value/stmvalue2 * .2,0,0.02,1),“In”,“Linear”,1)
end)
1 Like
Maybe there is something I am failing to understand?
1 Like
systemac
(systemac)
October 19, 2019, 3:05pm
#12
Can we see the code you are using to change the stamina value?
I am manually changing it as my player loads in for now for testing purposes
If it helps i also am using a local script but I do not see why that would effect anything.
systemac
(systemac)
October 19, 2019, 3:12pm
#15
Are you manually changing the value from the GUI that is in StarterGui or the GUI that is in your PlayerGui? I tested it and it seems to be working fine.
it is definately in the player gui
systemac
(systemac)
October 19, 2019, 3:14pm
#17
It is working perfectly fine for me. Check if you have everything in the right place maybe?
https://gyazo.com/d825f1d78917334299f0be8f5dfbf5b5
if you can check this out this is the model with the code it isnt working for me it isnt the whole gui just whats supposed to be working
https://www.roblox.com/library/4162626105/gui-bruh
I would post a picture or video but I can not.
systemac
(systemac)
October 19, 2019, 3:17pm
#20
Replace line 7 with:
stm:TweenSize(UDim2.new(value/stmvalue2 * .2,0,0.02,1),"In","Linear",1)
You were using a different type of " character.
1 Like