Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Game Logic.RoundModule:15: attempt to get length of a nil value?

local module = {}

local status = game.ReplicatedStorage:WaitForChild("Status")

function module.Intermision(length)
	for i = length,0,-1 do
		status.Value = "Next round starts in "..i.." seconds"
		wait(1)
	end
end

function module.SelectChapter()
	local rand = Random.new()
	local chapters game.ReplicatedStorage.Chapters:GetChildren()
	local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
	
	return chosenChapter
end

return module

1 comment

0

you never set the variable chapters

1 answer

You're missing a = at line 14.

local module = {}

local status = game.ReplicatedStorage:WaitForChild("Status")

function module.Intermision(length)
    for i = length,0,-1 do
        status.Value = "Next round starts in "..i.." seconds"
        wait(1)
    end
end

function module.SelectChapter()
    local rand = Random.new()
    local chapters = game.ReplicatedStorage.Chapters:GetChildren() -- Right here, make sure there's an equal sign.
    local chosenChapter = chapters[rand:NextInteger(1,#chapters)]

    return chosenChapter
end

return module

Make sure to carefully review your code. Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.