Voting GUI selecting maps from ServerStorage Issue

I have a problem with making my maps be in ServerStorage, have the voting system GUI select the map name from ServerStorage, and show it to the client. (What I had before was 3 options without name or picture because they were in ServerStorage and the client couldn’t see it)

What I did was make a few dummy maps in Lighting, and have the name of those maps be referenced and found in ServerStorage, to get the real map that people voted for, what it does instead is an error. If anyone knows another way of doing this then please tell me because I’m stuck at this for hours.

This part below is the one where it errors. It errors at the part where it tries copying the map from ServerStorage. chosenmap.value is the map chosen by the majority players after they voted.

		local map = chosenmap.Value
		print(choice1,choice2,choice3,winner,map,chosenmap)
		local map = ServerStorage:FindFirstChild(chosenmap.value) -- chosenmap.value is the name of the map that I'm trying to find btw root of the problem
		local clonemap = map:Clone() -- This is used to clone it to workspace and it errors here
More pieces of the script for context, incase someone needs it to solve my problem.
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local mapsfolder = game:GetService("Lighting"):WaitForChild("Maps")

local booleans = ReplicatedStorage.VotingSystem:WaitForChild("Booleans")
local variables = ReplicatedStorage.VotingSystem:WaitForChild("Variables")
local choice1 = variables:FindFirstChild("Choice1")
local choice2 = variables:FindFirstChild("Choice2")
local choice3 = variables:FindFirstChild("Choice3")
local winner = variables:FindFirstChild("Winner")
local timer = 25 --in seconds

while true do
	while true do
		local maps = mapsfolder:GetChildren()
		choice1.Value = maps[math.random(1,#maps)]
		table.remove(maps,table.find(maps,choice1.Value))
		choice2.Value = maps[math.random(1,#maps)]
		table.remove(maps,table.find(maps,choice2.Value))
		choice3.Value = maps[math.random(1,#maps)]
		table.remove(maps,table.find(maps,choice3.Value))
		wait(1)
		booleans:FindFirstChild("VotingSession").Value = true
		wait(20)
		booleans:FindFirstChild("RevealVotes").Value = true
		wait(10)
		booleans:FindFirstChild("VotingSession").Value = false
		booleans:FindFirstChild("RevealVotes").Value = false
		local chosenmap = winner.Value
		
		if not winner.Value then
			print("Something went wrong!")
			break
		end
		local map = chosenmap.Value
		print(choice1,choice2,choice3,winner,map,chosenmap)
		local map = ServerStorage:FindFirstChild(chosenmap.value) 
		local clonemap = map:Clone()
		
		

And yes I tried looking for this and I’m stuck for like 2 hours at this problem.

EDIT: Thanks for all the help.

2 Likes

What it says on the output??

Can you send screenshot?

1 Like

This is what it says.

1 Like
local map = chosenmap.Value
		print(choice1,choice2,choice3,winner,map,chosenmap)
local map = ServerStorage:FindFirstChild(chosenmap.value) 

Why there’s two map variables?

1 Like

It says the same thing if the variable is different, I don’t think that that is the problem.

1 Like

Wait a second…

local map = chosenmap.Value

It’s already an value then why you’re looking for value properties again?

1 Like

Can you provide a screenshot of the maps folder with the maps’ names?

1 Like

Basically I need the value property, from chosenmap.value and I need this value to be looked for in ServerStorage.

Try looking for string instead?

Don’t know if this is the cause, but this is an error too

local map = ServerStorage:FindFirstChild(chosenmap.value) 

When you reference the chosenmap variable here, i believe its a string value, and the value is stored in the Value property not the value, mind the casing.

Basically correct form of it:

local map = ServerStorage:FindFirstChild(chosenmap.Value) 

The string is in chosenmap.Value I can’t look for a static string because this string always changes.

I tried this and it gave me the same error.

chosenmap.Name

I don’t think it’s not gonna work.

Could you try this instead:

local map = ServerStorage:FindFirstChild(chosenmap) 

The reason I am saying is because you are assigning the winner.Value to that variable, not the instance’s Value property.

local map = ServerStorage:FindFirstChild(chosenmap.Name)

Try this one

Don’t do

local map = chosenmap.Value

This will technically create a variable (Most likely nil) instead of the actual value.

Instead, do something along the lines of this:

local map = chosenmap

Then you can use the .Value when getting the variable.

Make sure the Map is Archivable (Archivable needs to be on), is the map is not nil then that might be the problem. If Archivable is false, that might be why it can’t clone.

Archivable is a property of a model.

Try to print map before you try to clone it, if it’s nil, then that’s the problem.

Doesn’t work, because it just gets the name of the ObjectValue, not the value which I actually need

EDIT: Looking at other solutions give me 5 mins

I used the print command and it prints this: Choice1 Choice2 Choice3 Winner normandy Choice2
So “normandy” is the map name and I need that one then I reference the map variable in FindFirstChild and it does the same thing.

Code used:

	local map = chosenmap.Value
		print(choice1,choice2,choice3,winner,map,chosenmap)
		local mapss = ServerStorage:FindFirstChild(map)
		local clonemap = mapss:Clone()
		

@cakehunterman @WaterJamesPlough

I was talknig about printing mapss. Mapss is the map that you are trying to clone, print it to see that its not nil.

print(mapss) --Make sure it doesn't print nil.