Why do i get this error

Hey guys. Why am I getting this error?

That is line 38? What is the code for the function called highestVote?

Bildschirmfoto 2022-10-13 um 3.13.59 PM

That image isn’t loading properly for some reason.

oh wait maybe this one?

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.

1 Like

You’ll want it to look like return map, so get rid of the parentheses.

right. Lemme see if it works now