Local selected (a nil value);Color3 problem on text

Hello! I tried fixing this error many times, but it won’t do the work. Here’s the error:

  20:29:33.129 - Players.Enchanted_Tix.PlayerGui.Core.ShopScript:115: attempt to index local 'selected' (a nil value)

and here’s the script:

	script.Parent.MapFrame.Visible = true
	script.Parent.MapFrame.TitleOfMap.Text = selected.MapSettings.MapName.Value
	script.Parent.MapFrame.Difficulty.Text = selected.MapSettings.Difficulty.Value
	script.Parent.MapFrame.Difficulty.TextColor3 = Color3.fromHSV(game.ReplicatedStorage.ColorFolderTags:FindFirstChild(selected.MapSettings.Difficulty.Value))
	script.Parent.MapFrame.MapPerson.Text = selected.MapSettings.Owner.Value
	script.Parent.MapFrame.Visible = false

Questions you may be asking:

What type of script is this?: Local Script.

Please reply and if you have more questions I will answer them. If you tried to help me on the first part, heres another one:

Here’s the line of code:

script.Parent.MapFrame.Difficulty.TextColor3 = Color3.fromHSV(game.ReplicatedStorage.ColorFolderTags:FindFirstChild(selected.MapSettings.Difficulty.Value))

Please help. The only question I can answer is this one:

Is the value a Color3Value value?: Yes.

Please respond. Thank you :slight_smile:

The client seems to receive selected as nil, what exactly are you passing to the client?

I am passing the client a map. Here’s the local:

local SelectedMap = Maps[math.random(1, #Maps)]

Can we see the line of code where you call :FireClient() ?

local SelectedMap = Maps[math.random(1, #Maps)]

		for i, v in pairs(game.Players:GetChildren()) do
		game.ReplicatedStorage.FunctionsEvents.MapSelection:FireAllClients(SelectedMap, v)

Is the Maps variable a table or a Model/Folder? In addition to that, if the Maps are located in ServerStorage, they will not be visible to the client because ServerStorage doesn’t replicate to the client.

Good question. It is a model, though.

It is in a folder that is inside ServerStorage.

In that case, it won’t be visible to the client. You may want to move the map into ReplicatedStorage and then pass that instance of the map to the client.

I will try to do that, I guess.

Okay so good news and bad news. The good news is that your plan worked! The bad news is there is an error in my script:

script.Parent.MapFrame.Difficulty.TextColor3 = Color3.fromHSV(game.ReplicatedStorage.ColorFolderTags:FindFirstChild(selected.MapSettings.Difficulty.Value))


  21:17:20.696 - Color3.fromHSV requires three arguments

By the way, the value is a Color3Value.

Since the value is already a Color3 value, there’s no point or need for the constructor

script.Parent.MapFrame.Difficulty.TextColor3 = selected.MapSettings.Difficulty.Value

(Assuming selected.MapSettings.Difficulty.Value is a Color3 value)

Are you sure that will work? I don’t think it will…
Also selected.MapSettings.Difficulty.Value isn’t the colorvalue here…

You say this is a Color3 value, so yes it should work.

I updated the script and here’s what it looks like:

script.Parent.MapFrame.Difficulty.TextColor3 = Color3.fromHSV(game.ReplicatedStorage.ColorFolderTags:FindFirstChild(selected.MapSettings.Difficulty.Value).Value)
1 Like

if the returned value is already a Color3 here then you only need this portion not the Color3.fromHSV()
HSV stands for Hue, Saturation, and Value. Which you’re only trying to pass one argument, but as the name implies it takes three.

Thanks! Now I am going to continue my journey of my game.

Yours did work, too. I don’t know how to solution your map as well.