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

I need help with a script that inputs random numbers into a string that copies off into a TextLabel?

It is hard to simplify it, but I am making a script for a math game because my sister is struggling in math.

Basically there is a math center, and when you walk in you touch a block as you walk through, which generates 2 random numbers and copies them off to the question board.

But something is not working right, and I believe it has to do with

math.randomseed(tick)

Anyways here is the script, I will label what each thing is.

game.Workspace.Detector.Touched:connect(onTouched) -- Detector is the invisible block you walk through

function onTouched(part) 
math.randomseed(tick) -- What I suspect to be causing the problem
local Multiply1 = math.random(1,9) -- The random number
local Multiply2 = math.random(1,9) -- The OTHER random number
game.Workspace.QuestionSign.SurfaceGui.SIGN.Text = "What Is The Answer; "..Multiply1" + "..Multiply2"" -- What the text is supposed to change to.
end 

I hope you could help me, I would really appreciate it.

Thank you in advance

  • SupernalAura or Ment34591

1 answer

✓ Accepted answer

You tried to call math.randomseed(tick) as a Function.

math.randomseed(os.time()*1,1000)

If you simply change your code to math.randomseed(tick() * 1000) which should Be use after math.random() it will fix the issue by making os.timeget a different input every time. There’s absolutely no reason to use call a TICK Into the Numbers Place here, that’s just overkill—math.random / randomseed are perfectly fine for this task.

function onTouched(part) 	
local Multiply1 = math.random(1,9)
local Multiply2 = math.random(1,9)
	
math.randomseed(os.time()*1,1000) --os.time & randomseed should be use after, 		Math.Random()

game.Workspace.QuestionSign.SurfaceGui.SIGN.Text = ("What Is The Answer; "..Multiply1.." + "..Multiply2.."") --Reverbed Text Output!
end 

game.Workspace.Detector.Touched:connect(onTouched) --Touched Fire Should Be After Function!

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