Voting GUI selecting maps from ServerStorage Issue

I think you still haven’t understood it, anyways, with your new code could you try this:

local mapss = ServerStorage:FindFirstChild(chosenMap)

The reason I told you to do this, is because you are assigning the winner.Value to chosenMap variable earlier in your code. So its just the string now, .Value for it is nil.

Please correct me if I am wrong, but would recommend to try that code first.

1 Like

That doesn’t work either.

I think it’s nil because you haven’t added the .Value when printing or anything else in code when getting chosenmap

If what you say is true, and even when it looks for chosenmap it still nil, it means that there isn’t a map called Choice2, or it doesn’t exist yet

@cakehunterman a model doesn’t have a property called .Value , it shouldn’t print nil if there’s a model.

This is how ServerStorage looks like.

Ahhh I get it now, chosenmap is Choice2 (A StrignValue), you should look for: map since it’s the map name.
Your map value is the coloseseum, therefore, it is nil, since there isn’t a map called Choice2 (the StringValue’s name), there’s a map called colosseum which is the map varaible.

chosenmap is a value, Choice2 is the name.

Edit:
Now I get it even more :sweat_smile:, it was right in the beginning except for the Maps folder as @WaterJamesPlough said below me, it should have been chosenmap.Value in the beginning, the problem was the parent of the map.

The thing is that you are looking for the map in Server Storage whereas its in a folder named Maps inside Server Storage, after doing the changes @LightningLion58 has said above, you should change that FindFirstChild to this instead I believe:

local mapss = ServerStorage.Maps:FindFirstChild(map)
1 Like

Wait, if what you said is true, why is map equal to chosenmap.Value?

It’s true but you are printing the “model” of the map, that doesn’t exist, not the chosenmap’s value.
When I said it didn’t exist it was because :FindFirstChild returned nil, since it was looking for the Value’s name and not the value itself.

I changed chosenmap to map
I also added .Maps In front of ServerStorage

and it says the same thing. And returns nil.

@WaterJamesPlough

Could you print the type of the map variable, it seems like it isn’t a string. Because other than that I don’t see any more errors in the code now.

print(typeof(map))
1 Like

Its an instance, so this is the problem? How would I go about converting it to a string?

Yep, so you just need to do map.Name in the FindFirstChild. When you do print, I believe it prints the Name of it if its an instance.

1 Like

I am still not sure about this, try using type() instead of typeof(). If it prints string, you know it’s a string, else if it prints model, it might be your map.

Edit:
@WaterJamesPlough just asking, why would you look for the map again? It’s already the map’s model, there’s no need to FindFirstChild it again. map might print the name because that’s the string property of the model.

The reason its being looked for again is because the GUI can’t show the names of the maps from ServerStorage so there are folders in Lighting where the map is being chosen and then its being looked for again in ServerStorage (which is probably a primitive way of doing It)

1 Like

If you use type on an instance, it will return userdata but when you use typeof, it will return instance. You can check out this thread for more information: Can we detect what type a variable is? - #2 by harule


The OP has just done it that way, so I just told how to do it in the current code itself :slight_smile:

1 Like

I still don’t understand, you get the same Instance (The folder), therefore, why look for it again? It’s the same thing.

From my understanding: map is equal to ServerStorage.Maps:FindFirstChild(map.Name).

They are empty and are only there so the client can see the map names

And yeah, you could use the Server Storage folders itself like @LightningLion58 has suggested. Storing stuff in the Lighting Service, isn’t really organized in my opinion.

If you want to like make Shared Folders for Client and Server, you could use ReplicatedStorage, so both the Client & Server stuff could be done in less stuff, the current way works too, but this is just better organization and stuff.

1 Like

The reason I don’t have it in ReplicatedStorage and do it this more complicated way is to reduce lag, and I can see it contributing a lot to lag the more maps I add so I did it in ServerStorage to future proof it.

1 Like