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

My script wont get a new random number after first run? (easy)

I want the script to keep getting a new number every time the gui is pressed

No errors or anything but I dont understand why it wont get a new one and a new one and so on. Any help appriciated.

local RandomMathNumbers = math.random(1,1000)


script.Parent.MouseButton1Click:Connect(function()
	

		script.Parent.Text = RandomMathNumbers
	wait(5)
	script.Parent.Text = "Random number generator, idk either"
	
end)

1 comment

1

That's because the RandomMathNumbers is running one time because that part of the script runs once. Just put the local RandomMathNumbers inside of the script.Parent.MouseButton1Click function.

1 answer

✓ Accepted answer
local RandomMathNumbers = math.random(1,1000)
 
 
script.Parent.MouseButton1Click:Connect(function()
	 local RandomMathNumbers = math.random(1,1000)

	script.Parent.Text = RandomMathNumbers
		wait(5)
	script.Parent.Text = "Random number generator, idk either"
	 
end)

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