I have recently been making where I need trash to appear in a specific area, however my script doesnt work. The output says that there is a error in line 13.
local TrashSpawnHere = game.Workspace.TrashSpawnHere
local function CreateTrash()
local Trash = game.Workspace.TrashPart
local TrashClone = Trash:Clone()
TrashClone.Parent = game.Workspace
local TrashSpawnHereSizeX = TrashSpawnHere.Size.X
local XPostion = TrashSpawnHere.CFrame.X
print(XPostion)
local SecondValueX = XPostion - TrashSpawnHereSizeX
print(SecondValueX)
local XPositionRandom = math.random(XPostion,SecondValueX)
local TrashSpawnHereSizeZ = TrashSpawnHere.Size.Z
local ZPosition = TrashSpawnHere.CFrame.Z
print(ZPosition)
local SecondValueZ = ZPosition - TrashSpawnHere
print(SecondValueZ)
local ZPositionRandom = math.random(ZPosition,SecondValueZ)
end
while true do
CreateTrash()
wait(2)
end

4 comments
The numerical inputs within the math.radom function cannot be used for it's arethmetic operations
Is there a way I could rewrite the code, i have tried putting the actual numbers in instead of XPosition and SecondValueX, however it still returns an error.
Here´s the error : Workspace.TrashSpawn:13: bad argument #2 to 'random' (interval is empty)
I can't follow why didn't he just put numbers would be easier to use google to subtract that.