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

Unknown Error Found in Output in Map Radomization???

Asked by
tber8 37
7 years ago

I have been working on a new game and I came across an error in the output. This error said "No method name passed in __namecall for Object," and I cannot fix it. I was attempting to create a variable for a random map in the "Maps" folder. Here is the line:

local rndmmap = game.ReplicatedStorage.Maps(math.random())

What did I do wrong and how do I fix it?

~tber8 / TTC

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You are indexing in the line of code wrongly. Firstly, you should get all the children of the maps folder. Then, use math.random() to select the random index of the list of maps to select it.

Here. Let me show you:

--Lines of other code...
local maps = game.ReplicatedStorage.Maps:GetChildren()
local rndmmap = maps[math.random(1, #maps)]
--...Continue

If you have any questions, please leave a comment below. Thanks!

0
Thanks! tber8 37 — 7y
Ad

Answer this question