I am trying to generate a random number between 1 and GameID
local GameID = GetData()
TICK = tick()
math.randomseed(TICK)
local RANDOM = math.random(GameID)
local GameData = f(RANDOM)
but I keep getting this error
I only get this error in game, but not in studio.
and from the gyazo image GameID is not nil
I am being told it is an overflow error
Im not sure what GetData is, couldn’t you just workspace.GameId (this is probarly wrong) or a property of that sort
Its probably erroring because GetData() returns something else like a table or something instead of a number value
I tried printing math.random() with the specific GameID value that was there, if you remove a digit, it seems to work fine, perhaps you’re trying to access values that are too high? Though, that doesn’t explain why that error is read like that. Will experiment to find out whats the highest possible number to use.
math.random has problems with overflowing with numbers greater than (2^31)-1. You should use Randoms instead for large numbers since it doesn’t have that issue.
That’s a bug with math.random but it’ll have to be dealt with separately from this thread.
I tried math.random with that number in an online lua compiler and it worked.
Lua 5.3 while roblox uses 5.1.4 i think so yeah they must’ve fixed this.