---- Drop parts onto basePart ----
local rng = Random.new(time())
local basePart = game.Workspace.BasePart
local baseValueX = basePart.Size.X -- get baseParts X size
local baseValueZ = basePart.Size.Z
local baseAreaX = basePart.Position.X + baseValueX / 2 -- find CFrame and then add half the baseParts Size
local baseAreaZ = basePart.Position.Z + baseValueZ / 2
local baseAreaNegX = basePart.Position.X - baseValueX / 2
local baseAreaNegZ = basePart.Position.X - baseValueZ / 2
local positionY = 2
local function makePart()
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(1, 1, 1)
newPart.Anchored = true
newPart.CanCollide = false
newPart.Name = "SpawnedPart"
newPart.Shape = Enum.PartType.Ball
newPart.BrickColor = BrickColor.new("Lime green")
newPart.Position.X = rng:NextInteger(baseAreaNegX, baseAreaX)
newPart.Position.Z = rng:NextInteger(baseAreaNegZ, baseAreaZ)
newPart.Position.Y = positionY
newPart.Parent = game.Workspace
end
makePart()
Random.new() accepts one parameter, which is the seed: number. The function you needed to use was Random.new(seed: number)s :NextInteger if you wanted an integer (that is, a non-decimal value) or :NextNumber if you wanted a float (that is, a decimal value).
Apparently I didn’t know this, but from what @SubtotalAnt8185 stated before Random() does not work the way you originally thought it did
The way to use Random.new() (After just learning about it 10 seconds after whoops) is creating it into a variable on its own, then using one of the methods provided by it (rand.NextNumber, rand:NextNumber) to get the desired result that you want
(If you use rand.NextNumber) Reference the Random() datatype
Provide the Minimum Number
Provide the Maximum Number
Although I don’t think either the 2 of them matter apart from the parameters, you can call it like this:
---- Drop parts onto basePart ----
local basePart = game.Workspace.BasePart
local baseValueX = basePart.Size.X -- get baseParts X size
local baseValueZ = basePart.Size.Z
local baseAreaX = basePart.CFrame.X + baseValueX / 2 -- find CFrame and then add half the baseParts Size
local baseAreaZ = basePart.CFrame.Z + baseValueZ / 2
local baseAreaNegX = basePart.CFrame.X - baseValueX / 2
local baseAreaNegZ = basePart.CFrame.Z - baseValueZ / 2
local PositionY = 2
local rand = Random.new()
local function makePart()
local newPart = Instance.new("Part")
newPart.Size = Vector3.new(1,1,1)
newPart.Anchored = true
newPart.CanCollide = false
newPart.Name = "SpawnedPart"
newPart.Parent = game.Workspace
newPart.Shape = Enum.PartType.Ball
newPart.BrickColor = BrickColor.new("Lime green")
newPart.Position.X = rand:NextNumber(baseAreaNegX, baseAreaX)
newPart.Position.Z = rand:NextNumber(baseAreaNegZ, baseAreaZ)
newPart.Position.Y = PositionY
end
makePart()