I got some code from the "Map Chooser" wiki page from roblox. On a part of the script, it chooses a map. It picks from a folder called maps which is located in the ReplicatedStorage.
This is the line of code it is in (inside a function called "pickMap"):
local selectedIndex = math.random(1, #maps) local map = mapList[selectedIndex]:Clone()
"maps" is a variable outside the function:
local maps = replicatedStorage:WaitForChild("Maps")
This is the error I get:
ServerScriptService.Script:9: attempt to get length of upvalue 'maps' (a userdata value)
If you want the whole page of code, search "Map Chooser" on the roblox wiki.
You can't get the length of an Instance. You can however, get the number of children of said Instance, which you are meaning to do.
local selectedIndex = math.random(1, #maps:GetChildren()) local map = mapList[selectedIndex]:Clone()
maps
is a ROBLOX Object, probably a Model. You need to use GetChildren
on it to get a Table:
local maps = replicatedStorage:WaitForChild("Maps"):GetChildren()