I have no idea how to do this, I've attempting this to work through a GUI & be able to be triggered from a model if need be. Basically, lets use ArenaLights as the main model.
Lighting = game.Lighting ReplicatedStorage = game.ReplicatedStorage parts = game.Workspace.ArenaLights:GetChildren() -------------------------------- game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight) if arenalight == "BrightWhite" then --White Lighting parts.PointLight.Color = Color3.new(255/255,255/255,255/255) wait(0.01) elseif arenalight == "White" then parts.PointLight.Color = Color3.new(255/255,255/255,255/255) wait(0.01) elseif arenalight == "Blackout" then parts.PointLight.Color = Color3.new(0/255,0/255,0/255) wait(0.01) end end)
Thank you in advance for any help you may give and any time you spend on this!
Try This:
Lighting = game:GetService('Lighting') -- This line isn't needed though. ReplicatedStorage = game.ReplicatedStorage parts = game.Workspace.ArenaLights:GetChildren() -------------------------------- game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight) if arenalight == "BrightWhite" then --White Lighting for i,v in pairs(parts) do v.PointLight.Color = Color3.new(255/255,255/255,255/255) wait(0.01) end wait(0.01) elseif arenalight == "White" then for i,v in pairs(parts) do v.PointLight.Color = Color3.new(255/255,255/255,255/255) wait(0.01) end wait(0.01) elseif arenalight == "Blackout" then for i,v in pairs(parts) do v.PointLight.Color = Color3.new(0/255,0/255,0/255) wait(0.01) end wait(0.01) end end)
If I understood correctly you want to change all the PointLights inside of all the Parts inside of ArenaLights.
The simplest loop is just using a i, v pairs loop. This will loop through a list of items, in this case a list of all the children in the ArenaLights object, and give you the index (number) of the child and the child itself.
for index, child in pairs(game.Workspace.ArenaLights:GetChildren()) do -- Code in here will run for every single child independently. -- Example: child.PointLight.Color = Color3.fromRGB(255, 255, 255) end
The correct usage is using i,v instead of index, child. I fixed your code for you, but it'd be good practice to try to fix it yourself using the above information. I've also used Color3.fromRGB() instead of Color3.new() because it's easier to work with.
Lighting = game.Lighting ReplicatedStorage = game.ReplicatedStorage -------------------------------- game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight) local children = game.Workspace.ArenaLights:GetChildren() if arenalight == "BrightWhite" then --White Lighting for i, v in pairs(children) do v.PointLight.Color = Color3.fromRGB(255, 255, 255) end wait(0.01) elseif arenalight == "White" then for i, v in pairs(children) do v.PointLight.Color = Color3.fromRGB(255, 255, 255) end wait(0.01) elseif arenalight == "Blackout" then for i, v in pairs(children) do v.PointLight.Color = Color3.fromRGB(0, 0, 0) end wait(0.01) end end)