hi, how do i make random tips? i tried while true do but it just stops code
code here:
local tips = {
'test',
'tip2',
'tip3'
'tip4'
}
function Load()
local GameAssets = game:GetDescendants()
for i = 1, #GameAssets do
local GameAsset = GameAssets[i]
local Percentage = math.round(i / #GameAssets * 100)
ContentProviderService:PreloadAsync({GameAsset})
print(Percentage)
if i % 5 == 0 then
task.wait()
end
if i == #GameAssets then
task.wait(1)
print('Loaded!')
end
MainFrameBackgroundBarFill:TweenSize(UDim2.new(Percentage/100, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 1, true)
end
end
You can use a loop but just add a wait within the loop. If you don’t then it’ll timeout unless you are in a game that will crash the player.
The code I would suggest:
local textLabel = textLabel -- The TextLabel of the tip
coroutine.wrap(function() -- Lets code beneath it continue
while task.wait() do -- Won't crash even if the wait(1) was removed
textLabel.Text = tips[math.random(1, #tips)] -- Changes to random tip
wait(1) -- Wait until it changes
end
end()()
Place the coroutine outside of the function and add a debounce at the top. If the debounce == true then it’ll find the UI and change the tip till the debounce is false.