I read off this table thing of things and I print out the second index which is the Randow.new function but it only gives me the same number every time I print it
It looks like you’re just calling NextInteger once for each item and storing the result, so each time you read from the table you’re just reading the same stored value.
What I mean is you are only generating one random number for each of the table values. Each time you read the table it will not give you a new random number, it’s just giving you the number stored in the table.
I don’t exactly know the context of your script, but if this table is being duplicated then you would have to call NextInteger every time the table is copied.
I have a local script that is requiring the module that I have in above
tbl[2] is the random function
uis.InputBegan:Connect(function(i,t)
if t then return end
if i.KeyCode == Enum.KeyCode.F then
for idx, tbl in pairs(Item["Possible Items"]) do
for i,v in pairs(workspace:GetChildren()) do
if v.Name == tbl[1] then
Stuff:PickUp(plr,v, tbl[2])
end
end
end
end
end)
local random = Random.new(tick())
uis.InputBegan:Connect(function(i,t)
if t then return end
if i.KeyCode == Enum.KeyCode.F then
for idx, tbl in pairs(Item["Possible Items"]) do
for i,v in pairs(workspace:GetChildren()) do
if v.Name == tbl[1] then
Stuff:PickUp(plr,v, random:NextInteger(0, tbl[2]))
end
end
end
end
end)
I was thinking about doing something like this, nonetheless it worked and thank you for taking the time to help me, really thank you so much for your help