Yeah it does print nil, for some reason.
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.
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 , 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)
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.
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))
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.
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)
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
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.