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

attempt to get length of a number value how do i fic this?

trying to make a random map select but i keep geting this error "ServerScriptService.MainScript:39: attempt to get length of a number value - Server - MainScript:39"

local AvailableMaps = mapsFolder:GetChildren()

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

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

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

this dosnt work

local AvailableMaps = mapsFolder:GetChildren()

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

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

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

and this give me "ServerScriptService.MainScript:39: attempt to call a nil value - Server - MainScript:39"

any help or suggestions would be greatly apresiated

also 39 would be line 2 in this

sorry for spelling and formating

1 comment

0

It's math.random not math.ramdom. Secondly, you cannot do #n only #table because numbers are not tables.

1 answer

✓ Accepted answer

You've spelt it wrong. It's math.random, not math.ramdom.

Also, if your doing the AvailableMaps[] method, make sure the map names are by numbers so it wont error.

1 comment

0

thank i ficked the spelling and now its fix sorry about stupid qusetion dint notice it becuse im dislexic

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