Here is my script:
game.ReplicatedStorage.RandomizeItems.OnServerEvent:Connect(function() local function choose(tab) local n = math.random(1, #tab) local obj = tab[n] return obj end
local Amount = math.random(2,9)
if script.Parent:findFirstChild("Torso") then
for i=1, Amount do
local LocalPlr = game.Players:FindFirstChild(script.Parent.Name)
local Item = choose(game.ReplicatedStorage.BackpackItems:GetChildren())
wait(1.5)
Item:Clone()
Item.Parent = LocalPlr.Backpack
end
end
end)
It goes in the "StarterCharacterScripts" and is a server script.
It keeps getting this error:
RandomItems:3: bad argument #2 to 'random' (interval is empty)
Can you help?
(I cant find any ways to fix my code on my own or the internet)

1 comment
Also, you didn't need a RemoteEvent for this as I used the PlayerAdded event, which is used in a server script. This way you can do everything in one script :)