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

Getting Error: "ServerScriptService.Script:8: bad argument #2 to 'random' (interval is empty)"?

I can run this sometimes, and it will work, but it will only generate parts on the outside of the brick (but if I shrink it it generates fine?)

Code:


local spawnBase = workspace.Baseplate
local point1 = Vector2.new(-spawnBase.Position.X-(spawnBase.Size.X/2),spawnBase.Position.Z+(spawnBase.Size.Z/2))
local point2 = Vector2.new(spawnBase.Position.X+(spawnBase.Size.X/2),-spawnBase.Position.Z-(spawnBase.Size.Z/2))
local point3 = Vector2.new(-spawnBase.Position.X+(spawnBase.Size.X/2),-spawnBase.Position.Z-(spawnBase.Size.Z/2))
local point4 = Vector2.new(spawnBase.Position.X-(spawnBase.Size.X/2),spawnBase.Position.Z+(spawnBase.Size.Z/2))

local randomX = math.random(point1.X,point4.X)
local randomZ = math.random(point1.Y,point3.Y)

local part = Instance.new("Part"); part.Parent = workspace
part.Anchored = true
part.CFrame = CFrame.new(randomX,spawnBase.Position.Y+(spawnBase.Size.Y/2),randomZ)

Error: "ServerScriptService.Script:8: bad argument #2 to 'random' (interval is empty)"

2 comments

0

Remove the "Code:" so we can see the actual code better.

0

my bad, it doesnt work on the same line as text

1 answer

✓ Accepted answer

At line 8








local randomZ = math.random(point1.Y,point3.Y)

point1.Y is higher than point3.Y

The first argument of math random will be the minimum number and the second the maximum

2 comments

0

ah, I must not have saved my changes when I had it fixed originally, thanks!

0

If an answer has solved your problem please use the "accept answer" feature.

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