15:31:08.179 Players.Nimbzee.Backpack.Lightsaber.Functional.Server:505: attempt to index nil with 'FindFirstChild' - Server - Server:505
hello, I'm a beginner scripter that is still learning to code. I am receiving this error on line 505 but don't know why.
I have a data store that saves crystals. in the player's folder, there will be many different bool values saved. i.e green, one I have in my folder of saved data.
these were a mix taken from the toolbox, some help from others and myself.
there is a module script that has the colors, and the keys. you press the key on your keyboard and it changes the color.
module.colors = {
blue = {Outer = color(0, 136, 255); Inner = color(117, 212, 255); Key = Enum.KeyCode.B};
cyan = {Outer = color(52, 255, 242); Inner = color(170, 255, 255); Key = Enum.KeyCode.C};
green = {Outer = color(0, 170, 0); Inner = color(123, 255, 165); Key = Enum.KeyCode.G};
orange = {Outer = color(255, 85, 0 ); Inner = color(255, 180, 105); Key = Enum.KeyCode.T};
purple = {Outer = color(54, 12, 150); Inner = color(167, 128, 199); Key = Enum.KeyCode.P};
red = {Outer = color(198, 0, 3); Inner = color(255, 171, 171); Key = Enum.KeyCode.R};
white = {Outer = color(211, 211, 211); Inner = color(148, 200, 255); Key = Enum.KeyCode.Z};
jade = {Outer = color(63, 127, 94); Inner = color(255, 230, 105); Key = Enum.KeyCode.J};
teal = {Outer = color(0, 114, 127); Inner = color(255, 230, 105); Key = Enum.KeyCode.N};
silver = {Outer = color(122,122,122); Inner = color(255, 230, 105); Key = Enum.KeyCode.V};
pink = {Outer = color(255, 255, 0); Inner = color(255, 142, 246); Key = Enum.KeyCode.L};
yellow = {Outer = color(255, 255, 0); Inner = color(255, 230, 105); Key = Enum.KeyCode.Y};
}
there is a server script to check when they press one of these and change it like so. this is where the error is.
Recolor = function(data,plr)
local TargetBlade
if Dual then
TargetBlade = {
[1] = ActiveSabers[1].Blade,
}
if ActiveSabers[2] then
TargetBlade[2] = ActiveSabers[2].Blade
end
else
TargetBlade = Blades
end
for _, Blade in next, TargetBlade do
local Target = "Emitter"
if Blade.Name == "Blade2" then
Target = "Emitter2"
end
Blade.FX.Glow.Color = data.Outer
for _, v in next, Blade[Target]:GetChildren() do
if data[v.Name] then
if plr:FindFirstChild("Crystals"):FindFirstChild("Green") then
v.Color = ColorSequence.new(data[v.Name])
end
else
v.Color = ColorSequence.new(data.Outer, data.Inner)
end
end
end
end,
at the line where it says if plr:find first child seems to be where i get my error. im also confused on another question. how can i check the color in the folder without having to type all the colors manually? i am a beginner so any help would be appriciated. thanks alot!

3 comments
Confirm that plr is being passed as a valid value to the function?
I made an edit to my answer.
Make sure you are passing down plr in "Recolor" function.