Invalid argument #2 to 'random' (interval is empty)

I want to make it so every 10 seconds, it will choose a model from the chances, and spawn it within the plot.

I am using a math.random equation to determine where the part will spawn within the plot boundaries however it turns up the error mentioned in the title at line 23

local plot = game.Workspace:WaitForChild("Plot")
local crystals = game.ReplicatedStorage.Crystals

normal = crystals.BasicCrystal:Clone()
shiny = crystals.ShinyCrystal:Clone()
dm = crystals.DarkMatterCrystal:Clone()

local chances = {
	["Normal"] = 1,
	["Shiny"] = 2,
	["DM"] = 5,
}

local start = 0
local max = 25

while task.wait(10) do
	if start == 25 then
		return
	end
	if math.random(1,chances.Normal) then
		normal.Parent = game.Workspace.Plot
		normal.Posistion = Vector3.new(math.random(-11.75,50.25), math.random(5,5), math.random(-41.75, -109.25))
		start += 1
	end
end

math.random(-41.75, -109.25)

This is the reason why its erroring, you’re pretty much saying that -109 is bigger then -41.75.
To fix this simply just swap the values around and it should work fine.

math.random(-109.25, -41.75)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.