Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix error: attempt to index nil with 'WaitForChild'?

Asked by 3 years ago
-- Define variables

local Replicated = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")

local MapsFolder = ServerStorage:WaitForChild("Maps")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 500

local reward = 50

-- Game loop

while true do

end

    Status.Value = "Waiting for enough players" 

    repeat wait(1) until game.Players.NumPlayers >= 2

    Status.Value = "Intermission"

    wait(10)

    local plrs = {}

    for i, player in pairs(game.Players:GetPlayers()) do
        if player then
            table.insert(plrs,player) -- Add each player into plrs table
        end
    end

    wait(2)

    local AvailableMaps = MapsFolder:GetChildren()

    local ChosenMap =AvailableMaps[math.random(1,#AvailableMaps)]

    Status.Value = ChosenMap.Name.." Chosen"

    local ClonedMap = ChosenMap:Clone()
    CloneMap.Parent = workspace 

1 answer

Log in to vote
0
Answered by
ew_001 58
3 years ago

You did not give us the line hwere the error is, but i found it myself.

On line 9, ReplicatedStorage is not a valid varible, but Replicated is. Try to replace ReplicatedStorage with Replicated, as that is how you have written the varibles.

I hope this helps!

Ad

Answer this question