I am trying to make a tycoon game, but when I try to use an in pairs loop to change the transparency of a bunch of parts it says that the part in the table is a nil value.
local tycoon = script.Parent.Parent.Parent.Parent
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.UserId == tycoon.OwnerId.Value then
if script.Parent.Transparency == 0 then
if player.leaderstats.Cash.Value >= 1000 then
script.Parent.Transparency = 1
script.Parent.Parent.Part2.Transparency = 1
script.Parent.BillboardGui.Enabled = false
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 1000
local lightParts = {tycoon.Lights:GetDescendants()}
for i, v in pairs(lightParts) do
if v:IsA("Part") then -- this is were it gets the error
if v.Name == "Part" then
v.Transparency = 0
end
end
end
end
end
end
end
end)
This is what is in the Lights folder.
The error that I get.