Your issue lies in your usage of ~=.
local NewLight = LightFile:FindFirstChild(SectionCabin) ~= nil
Think about what this means. We're searching LightFile's children for SelectionCabin. But it doesn't end here, based on your code. You're essentially asking the interpreter if LightFile.SelectionCabin is not equal to nil. This means that NewLight is inherently a boolean value (true or false).
local SectionCabin = script.Parent.MODES.Section_Select.Value
local SideSelection = script.Parent.MODES.Side_Section.Value
local NewLight = LightFile:FindFirstChild(SectionCabin)
local LightSource = NewLight:FindFirstChild(SideSelection)
print('FIND')
I can't help with anything else if it continues to error, because I can't see the rest of your code. This solves your current error, though.
As a side note, watch out when storing values in variables. If I have an IntValue serving as a player's leaderstat, for example:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Parent = leaderstats
local PlayerKills = Kills.Value
end)
This is important. If you declare PlayerKills as Kills.Value, it may have unexpected behavior. For example, if you declare this variable, and the value of Kills changes, it is important to note that PlayerKills will not change with it. It is, at this point, static.
There is a time and place for declaring variables like this, but you simply have to know when and where it is!
1 comment
it is kinda weird on line 4