Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Intro GUI Math.Random Text Help?

Good evening,

I'm having some trouble here with an intro gui I'm working with and I want the texts to randomly be selected as loading procedures for the loading part of the intro GUI. For some reason it has all of the text filled at the same time and doesn't do anything more. I have below the script that I made and here is the set up:

text 2 (frame) ->MainTL (TextLabel) -->script -->tl1 -->tl2 -->tl3 -->tl4 -->tl5

local mtl = script.Parent.Parent.MainTL
local tl1 = script.Parent.tl1
local tl2 = script.Parent.tl2
local tl3 = script.Parent.tl3
local tl4 = script.Parent.tl4
local tl5 = script.Parent.tl5

while true do
	wait()
	math.random(1, 5)
	if math.random == 1 then
	wait(0.2)
	mtl.Text = tl1.Text.. "."
	wait(0.2)
	mtl.Text = tl1.Text.. ".."
	wait(0.2)
	mtl.Text = tl1.Text.. "..."
	wait(0.2)
	mtl.Text = tl1.Text.. "."
	mtl.Text = tl1.Text.. ".."
	wait(0.2)
	mtl.Text = tl1.Text.. "..."
	wait(0.2)
	end
	if math.random == 2 then
	wait(0.2)
	mtl.Text = tl2.Text.. "."
	wait(0.2)
	mtl.Text = tl2.Text.. ".."
	wait(0.2)
	mtl.Text = tl2.Text.. "..."
	wait(0.2)
	mtl.Text = tl2.Text.. "."
	mtl.Text = tl2.Text.. ".."
	wait(0.2)
	mtl.Text = tl2.Text.. "..."
	wait(0.2)
	end
	if math.random == 3 then
	wait(0.2)
	mtl.Text = tl3.Text.. "."
	wait(0.2)
	mtl.Text = tl3.Text.. ".."
	wait(0.2)
	mtl.Text = tl3.Text.. "..."
	wait(0.2)
	mtl.Text = tl3.Text.. "."
	mtl.Text = tl3.Text.. ".."
	wait(0.2)
	mtl.Text = tl3.Text.. "..."
	wait(0.2)
	end
	if math.random == 4 then
	wait(0.2)
	mtl.Text = tl4.Text.. "."
	wait(0.2)
	mtl.Text = tl4.Text.. ".."
	wait(0.2)
	mtl.Text = tl4.Text.. "..."
	wait(0.2)
	mtl.Text = tl4.Text.. "."
	mtl.Text = tl4.Text.. ".."
	wait(0.2)
	mtl.Text = tl4.Text.. "..."
	wait(0.2)
	end
	if math.random == 5 then
	wait(0.2)
	mtl.Text = tl5.Text.. "."
	wait(0.2)
	mtl.Text = tl5.Text.. ".."
	wait(0.2)
	mtl.Text = tl5.Text.. "..."
	wait(0.2)
	mtl.Text = tl5.Text.. "."
	mtl.Text = tl5.Text.. ".."
	wait(0.2)
	mtl.Text = tl5.Text.. "..."
	wait(0.2)
	end
end

2 comments

0

why is it so hard to put it in for loops?

0

This method would work better if you use elseif instead of if each time, but I would recommend switching to a loop to make things more efficient.

1 answer

local mtl = script.Parent.Parent.MainTL
local labels = script.Parent

while wait() do
    local rand = math.random(1, 5)
    local label = labels["tl" .. tostring(rand)]
    for i=1,6 do
        local maths = i % 3
        mtl.Text = label.Text .. (maths == 1 and "." or maths == 2 and ".." or maths == 0 and "...")
        wait(0.2)
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.