I have recently made a circular progress bar off a tutorial on YouTube however I want to use this progress bar as a magic bar such as a mana bar with my own values. But no matter how hard I try it just goes straight back to 100… Heres the original script!
local tweenService= game:GetService("TweenService")
local progress = script.Parent
local left = progress:WaitForChild("Left"):WaitForChild("Circle")
local right = progress:WaitForChild("Right"):WaitForChild("Circle")
local center = progress:WaitForChild("Centre")
local percentage = Instance.new("NumberValue")
percentage:GetPropertyChangedSignal("Value"):Connect(function()
local rotation = math.floor(math.clamp(percentage.Value * 3.6, 0, 360))
right.UIGradient.Rotation = math.clamp(rotation, 0, 180)
left.UIGradient.Rotation = math.clamp(rotation, 180, 360)
end)
task.wait()
local tween = tweenService:Create(
percentage,
TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),
{
Value = math.random() * 100
}
)
tween:Play()
That is the script and I want to use it so that the circle around it doesn’t fill in fully at 100 and it fills half way at like 500 not 50
idk but currently the rotation is calculated as percentage.Value * 3.6, which assumes a maxiumum value of 100 (since 100 * 3.6 = 360 degrees if I do know math correctly).
this script is full of magic and should work:
local tweenService= game:GetService("TweenService")
local progress = script.Parent
local left = progress:WaitForChild("Left"):WaitForChild("Circle")
local right = progress:WaitForChild("Right"):WaitForChild("Circle")
local center = progress:WaitForChild("Centre")
local percentage = Instance.new("NumberValue")
percentage:GetPropertyChangedSignal("Value"):Connect(function()
local rotation = math.floor(math.clamp(percentage.Value / 1000 * 360, 0, 360))
right.UIGradient.Rotation = math.clamp(rotation, 0, 180)
left.UIGradient.Rotation = math.clamp(rotation, 180, 360)
end)
task.wait()
local tween = tweenService:Create(
percentage,
TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),
{
Value = math.random() * 1000 -- Adjusted to match the new scale
}
)
tween:Play()