Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can some help change material at Time A and Time B?

Asked by 4 years ago

Can someone help me edit this script to change to Neon when it reaches a certain time, but changes back to SmoothPlastic when it reaches another certain time?

local Lighting = game:GetService("Lighting");

-- Our while loop
while true do

-- Checking if the time is 18 or more.
if Lighting.ClockTime >= 18 then

    -- Let's change the lamp's material to Neon!
    script.Parent.BrickColor = BrickColor.new("Pink")

    else

    -- Change it to SmoothPlastic if it isn't late :D
    script.Parent.Material = Enum.Material.SmoothPlastic;
end

wait(1) -- Waits a second before continuing
end

2 answers

Log in to vote
0
Answered by
Norbunny 555 Moderation Voter
4 years ago
Edited 4 years ago

Instead of using a while loop, connect to :GetPropertyChangedSignal() or LightingChanged.

local lighting = game:GetService("Lighting")

lighting:GetPropertyChangedSignal("TimeOfDay"):Connect(function() 
    -- your code here
end)

To change a part's material to neon, you do it in thes same way that you did for SmoothPlastic, but replacing it with Neon

part.Material = Enum.Material.Neon

Documentation on GetPropertyChangedSignal, Materials

Ad
Log in to vote
0
Answered by 4 years ago

pink isnt a material, its a colour.

local Lighting = game:GetService("Lighting");
while true do
    if Lighting.ClockTime >= 18 then
        script.Parent.Material = Enum.material.Neon
        script.Parent.BrickColor = BrickColor.new("Pink")
        else
            script.Parent.Material = Enum.Material.SmoothPlastic;
    end
wait(1)
end

0
oops forget about the brickcolor shufflebotandrew 2 — 4y

Answer this question