How could I fix this? attempt to call method 'GetChildren' (a nil value)
I got an error saying:
Workspace.Script:4: attempt to call method 'GetChildren' (a nil value)
19:41:56.037 - Stack Begin
19:41:56.037 - Script 'Workspace.Script', Line 4 - global FindFirstInTable
I don't get why I got this error,why did I get it?
01 | PlayerWithTools = { "Zombomafoo" , "Player1" } |
03 | function FindFirstInTable(Table,String) |
04 | for _,v in pairs (Table:GetChildren()) do |
13 | game.Players.PlayerAdded:connect( function (Player) |
14 | Player.CharacterAdded:connect( function (Character) |
16 | Player = FindFirstInTable(PlayerWithTools,Player.Name) |
18 | for _,Tools in pairs (game.ServerStorage:GetChildren()) do |
19 | ClonedTools = Tools:Clone() |
20 | ClonedTools.Parent = Player.Backpack |
--Fixed Script--
01 | PlayerWithTools = { "Zombomafoo" , "Player1" } |
03 | function FindFirstInTable(Table,String) |
04 | for _,v in pairs (Table) do |
13 | game.Players.PlayerAdded:connect( function (Player) |
14 | Player.CharacterAdded:connect( function (Character) |
16 | Player = FindFirstInTable(PlayerWithTools,Player.Name) |
18 | for _,Tools in pairs (game.ServerStorage:GetChildren()) do |
19 | ClonedTools = Tools:Clone() |
20 | ClonedTools.Parent = Player.Backpack |