-
What do you want to achieve? I’m trying to make a bar that displays how much of a value is left
-
What is the issue? The part is instantly changing to size 2,2,1 and wont change
-
What solutions have you tried so far? I tried looking up tutorials on youtube and nothing was showing me what I need to do
while wait(0.1) do
script.Parent.Size += Vector3.new(2,2,750/script.Parent.Parent.Candy.Value)
end
What about using tweens instead? TweenService
Can’t believe I didn’t think of that, I’ll try that out
It works as a tween, but is there a way to not have the size at Z 1
What do you mean?? Like trying to not change the z value?
No, how do I change it from 1 because its stuck at 1
When you want to change the z just change it in the tween if that’s what you need
Does Candy.Value
actually change? What is Candy.Value
?
If Candy.Value
shows the user’s current candy, you should instead do
function UpdateProgressBar(value: number)
script.Parent.Size = Vector3.new(2,2,750/script.Parent.Parent.Candy.Value)
end
script.Parent.Parent.Candy.Changed:connect(UpdateProgressBar)
UpdateProgressBar(script.Parent.Parent.Candy.Value)
to take advantage of Roblox’s event-based system.
Of course, you should instead use TweenService:
local TweenService = game:GetService("TweenService")
function UpdateProgressBar(value: number)
TweenService:Create(
script.Parent,
TweenInfo.new(0.1),
{
Size = Vector3.new(2,2,750/script.Parent.Parent.Candy.Value)
}
):Play()
script.Parent.Size = Vector3.new(2,2,750/script.Parent.Parent.Candy.Value)
end
script.Parent.Parent.Candy.Changed:connect(UpdateProgressBar)
UpdateProgressBar(script.Parent.Parent.Candy.Value)