local REMOTE = Instance.new("RemoteEvent") REMOTE.Name = "Box_event" REMOTE.Parent = game.ReplicatedStorage game.ReplicatedStorage.Box_event.OnServerEvent:Connect(function(Player,Item) local ItemsList = game.ServerStorage.Items:GetChildren() if (Player.Character.HumanoidRootPart.Position - Item.Position).magnitude < 10 then local ChosenItem = math.random(1, #ItemsList) local Clone = game.ServerStorage.Items[ChosenItem]:Clone() -- problem Clone.Parent = Player.Backpack end end)
On the math.random, I want it to choose a number and on the next line, copy that tool that is that number in the folder. But it only returns a number instead.
You're actually very close. Your ItemsList table has an index of all of the items in the folder already, so after using math.random(1, #ItemsList), there is no need to retrieve the folder again, you could just do
local Clone = ItemsList[ChosenItem]:Clone()
or even
local Clone = ItemsList[math.random(1, #ItemsList)]:Clone()
and save a line.
Edit: I should probably also explain why you can pull it from ItemsList and not from the folder itself. The ItemsList that gets the children from the folder is a table that recognizes the position in the table as a numeric value, whereas the folder itself doesn't recognize a position as a child.