Hello there, my game has a neon city, and the windows have the neon material as lighting. I have made a script for turning on and off lights at night, and was wondering if it is possible to make all neon parts in a model turn into smoothplastic at day?
You would need to get all the neon parts you want to change in order to do this. I would suggest to do this with either parenting the neon parts to the same source or with CollectionService. Ask if you would like me to show you how to do this with CollectionService, which would require manually tagging the neon parts.
Here’s some scripting that would achieve this.
local NightBegin = 19 -- Time when night beings
local NightEnd = 7 -- Time when night ends
local Lighting = game:GetService("Lighting")
local NeonParts = workspace:WaitForChild("NeonParts") -- Set this to a object which contains the neon parts
local NeonState = true
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local CurrentTime = Lighting.ClockTime
if (not NeonState) and CurrentTime >= NightBegin or CurrentTime <= NightEnd then
for _, Part in pairs(NeonParts:GetChildren()) do
Part.Material = Enum.Material.Neon
end
NeonState = true
elseif NeonState then
for _, Part in pairs(NeonParts:GetChildren()) do
Part.Material = Enum.Material.SmoothPlastic
end
NeonState = false
end
end)
Yikes, there’s no way to just select neon parts?
If I were you, I’d make a folder in the workspace (named “Lights”) and keep all the lights in there. Then this script would work.
local Lights = game.Workspace.Lights:GetChildren()
for _, v in pairs(Lights) do
v.Material = "Your material name"
end
Make this code run whenever you want to change them.
2 Likes