They Don't Sync

Hello There,

I am trying to make two Textlabels Have the Same Number and Make them have a random number.

image

while true do 
	for i=1,100 do

script.Parent.Part2.SurfaceGui.TextLabel1.Text = math.random(1,9)
script.Parent.Part1.SurfaceGui.TextLabel1.Text = math.random(1,9)

	

script.Parent.Part2.SurfaceGui.TextLabel2.Text = math.random(01,99)
script.Parent.Part1.SurfaceGui.TextLabel2.Text = math.random(01,99)


wait(1800)
end 
end

How Do I make it Sync Random Numbers If Could Point out What Is stopping It That would be great :smiley:

1 Like

math.random() might be yielding your script, causing this synchronization issue. Try storing it in a variable and you should expect the desired result:

while true do 
	for i=1,100 do
local num1 = math.random(1, 9)
script.Parent.Part2.SurfaceGui.TextLabel1.Text = num1
script.Parent.Part1.SurfaceGui.TextLabel1.Text = num1

	
local num2 = math.random(1, 99) 
script.Parent.Part2.SurfaceGui.TextLabel2.Text = num2
script.Parent.Part1.SurfaceGui.TextLabel2.Text = num2 -- Initialise another variable if you need a different value for this.


task.wait(1800) -- Also use task.wait
end 
end
3 Likes

(post marked for deletion for privacy reasons)

It Worked! Thank you For the Help :slight_smile:

1 Like

math.random is not a yielding function. It is a function that returns a number between X-to-Y.
If the issue is that it’s taking too long to get to the next random number, the OP should lower the wait time. 1800 seconds equates to 30 minutes, half an hour.