Hey! How is it going! I hope you are having a great day! I am currently creating Christmas Lights! However, it is not working.
The Christmas Lights:
local ServerStorage = game:GetService("ServerStorage")
local ServerEvents = ServerStorage.ServerSideEvents
for _, Lights in pairs(script.Parent:GetChildren()) do
if Lights:IsA("BasePart") then
ServerEvents.ChristmasLights:Fire(Lights)
end
end
The color changer:
local ServerStorage = game:GetService("ServerStorage")
local ServerSideEvents = ServerStorage.ServerSideEvents
local LightsTable = {}
ServerSideEvents.ChristmasLights.Event:Connect(function(Light)
table.insert(LightsTable, Light)
end)
while true do
for _, ChristmasLight in pairs(LightsTable) do
local Generated = Random.new()
local R = Generated:NextInteger(0, 255)
local G = Generated:NextInteger(0, 255)
local B = Generated:NextInteger(0, 255)
ChristmasLight.Color = Color3.fromRGB(R, G, B)
end
wait(0.5)
end
No errors, the lights are simply just not changing colors.
Code in your color changing script instead of using a Bindable in this case?
local ServerStorage = game:GetService("ServerStorage")
local ServerSideEvents = ServerStorage.ServerSideEvents
local LightsTable = {}
for _, Lights in pairs((Wherever the tree is):GetChildren()) do
if Lights:IsA("BasePart") then
table.insert(LightsTable, Lights)
end
end
while true do
for _, ChristmasLight in pairs(LightsTable) do
local Generated = Random.new()
local R = Generated:NextInteger(0, 255)
local G = Generated:NextInteger(0, 255)
local B = Generated:NextInteger(0, 255)
ChristmasLight.Color = Color3.fromRGB(R, G, B)
end
wait(0.5)
end
The thing is, there are a lot of Christmas lights I want to add. Writing every single one is hard to do + I could easily update it if needed. That is why I chose to do it they way I did it.
I also added
local RunService = game:GetService("RunService")
RunService.Heartbeat:Wait()
After adding the variables, and they seem to run every time. Should I try :WaitForChild() (I try to avoid it idk why)
I am surprised I didn’t realise that from the title, my bad! But the same should still apply, just parent all the light models to a folder and loop through that folder
Thats strange… It is the same problem. The script isn’t running…
local ServerStorage = game:GetService("ServerStorage")
local ServerSideEvents = ServerStorage.ServerSideEvents
local LightsTable = {}
ServerSideEvents.ChristmasLights.Event:Connect(function(Light)
for _, ChristmasLights in pairs(workspace.ChristmasLights:GetDescendants()) do
if ChristmasLights:IsA("BasePart") then
table.insert(LightsTable, ChristmasLights)
end
end
end)
while true do
for _, ChristmasLight in pairs(LightsTable) do
local Generated = Random.new()
local R = Generated:NextInteger(0, 255)
local G = Generated:NextInteger(0, 255)
local B = Generated:NextInteger(0, 255)
ChristmasLight.Color = Color3.fromRGB(R, G, B)
end
wait(0.5)
end
No need for it to be in an Event connection, put it standalone
for _, ChristmasLights in pairs(workspace.ChristmasLights:GetDescendants()) do
if ChristmasLights:IsA("BasePart") then
table.insert(LightsTable, ChristmasLights)
end
end