Hey guys. Why am I getting this error?
That is line 38? What is the code for the function called highestVote?
That image isn’t loading properly for some reason.
That function doesn’t return map, I assume you meant to return it?
No, it should pick the Map with the highest vote.
Right so you call the function, set map
to nil and highest
to 0, then loop through votes
to find the map with the most votes. At the end, map
and highest
refer to the most voted for map and the number of votes it has.
And then nothing happens, the function doesn’t return anything and map
and highest
go out of scope and become nil as the function ends.
And then back on like 38, you get this because the function didn’t return anything:
local selectedMap = ReplicatedStorage.Maps[nil]:Clone()
so what do I have to do to fix this problem?
Return map
in the function. That should fix it so long as map
is a string. If map
isn’t a string, you’ll need to show me how you are creating the votes
table.
You’ll want it to look like return map
, so get rid of the parentheses.