This problem I really don’t understand.
(Making a ‘power surge’ event for context) so I fixed a bug where a while-do loop continuously reactivated the surge because of increasing value; replaced it with a repeat-until loop. Only this seems to have rendered the event dysfunctional?
The surge starts fine with the lights and sound growing, but the power never shuts down (as it would with my previous while-do loop). Do I need to adjust something so that the script and the loop will cooperate together? Or is there another way to stop a while-do loop from increasing further after a certain value is reached?
Multiple scripts contributing to the surge event are affected, but this is my simplest one
surge.Changed:Connect(function()
if surge.Value >= 1000 then
local info = TweenInfo.new(
5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local goals ={Volume = 6}
local EarPopper = TweenService:Create(buzz, info, goals)
EarPopper:Play()
if buzz.Volume == 6 then
EarPopper:Cancel()
script.Parent.Blackout:Play()
buzz.Volume = 0
end
end
end)