We spawn or respawn i should get 3 random weapon
ServerScriptService.Script:21: attempt to index nil with 'Clone'
Stack Begin
Script 'ServerScriptService.Script', Line 21 - function onCharacterAdded
Stack End
local RS = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local Folder = RS:WaitForChild("Folder") local function onCharacterAdded(character) local Tools = Folder:GetChildren() local ToolsTable = Tools local chosenTools = {} repeat local selectedIndex = math.random(1, #ToolsTable) table.insert(chosenTools, ToolsTable[selectedIndex]) table.remove(ToolsTable, selectedIndex) until #chosenTools >= 3 -- Numbers of tools going to give local plr = Players:GetPlayerFromCharacter(character) for i = 1, 4, 1 do print(i) -- Index print(chosenTools[i]) -- Tools local ToolsCloned = Folder:FindFirstChild(chosenTools[i]):Clone() ToolsCloned.Parent = plr.Backpack end end local function onAdded(player) player.CharacterAdded:Connect(onCharacterAdded) -- Triggers when the player spawns or respawns end Players.PlayerAdded:Connect(onAdded)