attempt to index nil with 'GetChildren' Line 56?
Asked by
4 years ago Edited 4 years ago
i've been trying to fix this for the past 3 days, please help
003 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
005 | local ServerStorage = game:GetService( "ServerStorage" ) |
007 | local MapsFolder = ServerStorage:WaitForChild( "Maps" ) |
009 | local Status = ReplicatedStorage:WaitForChild( "Status" ) |
011 | local GameLength = 180 |
018 | Status.Value = "2 players needed to start the game" |
020 | repeat wait( 1 ) until game.Players.NumPlayers > = 2 |
022 | Status.Value = "Intermission" |
028 | for i, player in pairs (game.Players:GetPlayers()) do |
031 | table.insert(plrs,player) |
037 | local availableMaps = MapsFolder:GetChildren() |
039 | local ChosenMap = availableMaps [ math.random( 1 ,#availableMaps) ] |
041 | Status.Value = ChosenMap.Name.. " was picked" |
043 | local ClonedMap = ChosenMap:Clone() |
045 | ClonedMap.Parent = workspace |
050 | local SpawnPoint = ClonedMap:FindFirstChild( "SpawnPoints" ) |
052 | if not SpawnPoint then |
053 | print ( "Spawnpoints is not found" ) |
056 | local AvailableSpawnPoint = SpawnPoint:GetChildren() |
058 | for i, player in pairs (plrs) do |
060 | character = player.Character |
064 | character:FindFirstChild( "Torso" ).CFrame = AvailableSpawnPoint [ 1 ] |
065 | table.remove(AvailableSpawnPoint, 1 ) |
069 | local Sword = ServerStorage.Sword.Clone() |
070 | Sword.Parent = player.Backpack |
072 | local GameTag = Instance.new( "BoolValue" ) |
073 | GameTag.Name = "GameTag" |
074 | GameTag.Parent = player.Character |
089 | Status.Value = "Starting Game" |
092 | for i = GameLength, 0 ,- 1 do |
094 | for x, player in pairs (plrs) do |
096 | character = player.Character |
097 | if not character then |
100 | if character:FindFirstChild( "GameTag" ) then |
101 | print (player.Name.. "is still in the game" ) |
105 | print (player.Name.. "has been removed" ) |
111 | print (player.Name.. "has been removed" ) |
115 | Status.Value = i.. " time left, and " ..plrs.. " Players left" |
118 | Status.Value = plrs [ 1 ] .Name.. " has won the game." |
119 | plrs [ 1 ] .leaderstats.Coins.Value = plrs [ 1 ] .leaderstats.Coins.Value + 200 |
123 | elseif #plrs = = 0 then |
124 | Status.Value = "Sadly, no one won" |
128 | Status.Value = "Time's up lads'. Good luck next time" |
137 | for i, player in pairs (game.Players:GetPlayers()) do |
138 | character = player.Character |
140 | if not character then |
143 | if character:FindFirstChild( "GameTag" ) then |
144 | character.GameTag:Destroy() |
146 | if player.Backpack:FindFirstChild( "Sword" ) then |
147 | player.Backpack.Sword:Destroy() |
149 | if character.Backpack:FindFirstChild( "Sword" ) then |
150 | character.Sword:Destroy() |
155 | player:LoadCharacter() |
163 | Status.Value = "Game ended" |
this script is from alvinblox, but i cant seem to find out how to fix it