So i’m making an infinite version of 3008, and it works perfectly, however, when i play on mobile, i see that everywhere i go it spawns the same exact plot. I only see this on mobile, not on pc.
It only happens when a plot is placed in a negative coordinate. So everything is normal if it’s a positive.
This is the ‘formula’ i’m using, where x and y are the coordinates of the plot, which is added with a random seed, so that the map is different every time you play
-- Full script later in this post
local Random = Random.new(x + Randomseed..math.abs(y + Randomseed))
local randomNumber = Random:NextInteger(1, totalWeight)
This is what that issue looks like:
I have looked on the devforum for answers, and I only learned that this is acutally roblox’s fault, and that I can’t acutally fix it. But that won’t fix the problem.
If there are any questions i will try to answer them
Game: 3008 Infinite - Roblox
EDIT:
To clear up some confusion, i will explain the entire script:
Loot table Script
function PlotService:GetRandomItemFromLootTable(lootTable, x, y)
Randomseed = require(ReplicatedStorage.Randomseed).Seed
local totalWeight = getTotalWeightOfLootTable(lootTable)
local random = Random.new(x + Randomseed..math.abs(y + Randomseed))
local randomNumber = random:NextInteger(1, totalWeight)
-- The randomNumber variable is used here
for _, entry in ipairs(lootTable) do
if randomNumber <= entry.Weight then
return entry.Model
else
randomNumber = randomNumber - entry.Weight
end
end
end
Loot table
local PlotWeights = {
["Plots"] = {
{Model = PlotModels[1], Weight = 4000},
{Model = PlotModels[2], Weight = 5000},
{Model = PlotModels[3], Weight = 5000},
{Model = PlotModels[4], Weight = 3500},
{Model = PlotModels[15], Weight = 4000},
--40%, 17500 Weight
{Model = PlotModels[5], Weight = 4000},
{Model = PlotModels[6], Weight = 3500},
{Model = PlotModels[7], Weight = 2000},
{Model = PlotModels[8], Weight = 3625},
--30%, 13125 Weight
{Model = PlotModels[9], Weight = 2600},
{Model = PlotModels[10], Weight = 2800},
{Model = PlotModels[11], Weight = 3400},
{Model = PlotModels[12], Weight = 2025},
{Model = PlotModels[13], Weight = 2300},
--30%, 13125 Weight
}
}
Keep in mind that everything in the loot table is sorted later in the script
I’m using a loot table system, to make some plots are rarer than others, so i need a random number that is between 1 and the total amount of weight, which is then compared with the weights you see in the loot table