I’m not much of a scripter and having a little bit of trouble with this script I’m trying to make.
I’m trying to make it so that all of the children of the model each change transparency and material at the same time
local light = game.Workspace.Interior.Kitchen.Chandelier.FireLight:GetChildren()
local pointLight = game.Workspace.Interior.Kitchen.KitchenLight.PointLight
script.Parent.MouseClick:Connect(function()
pointLight.Enabled = not pointLight.Enabled
for i, child in light do
light.Material = Enum.Material.Plastic
light.Transparency = .5
end
if pointLight.Enabled == true then
for i, child in light do
light.Material = Enum.Material.Neon
light.Transparency = 0.1
end
end
end)
None of the values of the children of “FireLight” change, I was curious if anyone would be able to help. Thank you!
Hey man! The problem here is you need to refer to the individual object as “child” and not “light”. Here’s the correct modified version of your script.
local fireLight = game.Workspace.Interior.Kitchen.Chandelier.FireLight:GetChildren()
local pointLight = game.Workspace.Interior.Kitchen.KitchenLight.PointLight
script.Parent.MouseClick:Connect(function()
pointLight.Enabled = not pointLight.Enabled
for i, child in ipairs(fireLight) do
child.Material = Enum.Material.Plastic
child.Transparency = 0.5
end
if pointLight.Enabled then
for i, child in ipairs(fireLight) do
child.Material = Enum.Material.Neon
child.Transparency = 0.1
end
end
end)