I want to make it so the green bar doesn’t go over the background,
but I don’t know how to limit the tween to stay at cost
I tried to look on youtube and devforum, but never got a clear answer.
-- REBIRTH PERCENTAGE TWEEN
RebirthColor2:TweenSize(UDim2.new(Clicks.Value/RebirthCost.Value, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.25, true)
Clicks.Changed:Connect(function()
RebirthColor2:TweenSize(UDim2.new(Clicks.Value/RebirthCost.Value, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.25, true)
end)
RebirthCost.Changed:Connect(function()
RebirthColor2:TweenSize(UDim2.new(Clicks.Value/RebirthCost.Value, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.25, true)
end)
Hi Azolity,
Take a look at the math library, specifically math.clamp()
Example usage:
local numberA = math.clamp(10, 0, 9)
→ numberA will be equal to 9 instead
Hey! This was my very first post! So thanks for the help!
I don’t know if the way I did the tween was efficient, but it works
-- REBIRTH PERCENTAGE TWEEN
local function updateTween()
local percentage = math.clamp(Clicks.Value / RebirthCost.Value, 0, 1)
RebirthColor2:TweenSize(UDim2.new(percentage, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.25, true)
if percentage >= 1 then
RebirthColor2:TweenSize(UDim2.new(1, 0,1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.25, true)
end
end
updateTween()
Clicks.Changed:Connect(updateTween)
RebirthCost.Changed:Connect(updateTween)
system
(system)
Closed
#4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.