local Bar = script.Parent:WaitForChild("Bar")
local IntervalDisplay = script.Parent:WaitForChild("Top"):WaitForChild("Interval")
while true do
local Interval = game:GetService("ReplicatedStorage"):WaitForChild("GrowthIntervalInfo"):WaitForChild("Interval")
IntervalDisplay.Text = tostring(Interval.Value)
Bar:TweenSize(UDim2.new(0,0,0.025,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Linear,60)
task.wait(60)
Bar:TweenSize(UDim2.new(1,0,0.025,0))
end
The interval will be displayed as the previous and the bar will not shrink when it restarts for the new interval
I don’t understand what the problem is. Also, do not use :GetService() multiple times. (Especially in a while loop) Define ReplicatedStorage at the beginning of your code.
The problem is that once the 60 second tween ends when the loop restarts it wont display the correct interval nor will it start the 60 second tween again
local Bar = script.Parent:WaitForChild("Bar")
local IntervalDisplay = script.Parent:WaitForChild("Top"):WaitForChild("Interval")
local Interval = game:GetService("ReplicatedStorage"):WaitForChild("GrowthIntervalInfo"):WaitForChild("Interval")
while true do
task.wait(0.1)
IntervalDisplay.Text = tostring(Interval.Value)
Bar:TweenSize(UDim2.new(1,0,0.025,0))
repeat wait() until Bar.Size = UDim2.new(1,0,0.025,0)
Bar:TweenSize(UDim2.new(0,0,0.025,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Linear,60)
task.wait(60)
end
If the Interval doesn’t change while the 60 seconds loop is running, then you can do this outside and before the loop:
i cannot have it fire everytime the interval changes bc that would look laggy also i dont want the repeat wait bc if theres an issue then it will be too long
It is bad because it slows down your script every time you use the method. You are recalling the service multiple times which could be defined at the beginning of your script. You continuously reload all of the service’s properties every time you use it, when you could use a variable outside the loop.