Hello, I want to create a part that changes the material after a certain time.
How can I make one?
Thank you.
Depending on the certain time, you can change the Part’s Material by setting the Enum
of the Material to whatever you want to change it to:
local TimeToWait = 5
local Part = workspace.Part
wait(TimeToWait)
Part.Material = Enum.Material.Neon
Just a simple example you can experiement & mess around with
Thanks, but I meant “time” by ClockTime.
If I want ClockTime, do I change the “TimeToWait” to something else?
For example, I want the part to change the material after 20 ClockTime and change back again at 6 ClockTime. Thanks!
Ah, well what we could do then is keep detecting when the ClockTime
property changes using the GetPropertyChangedSignal
function, and check if the current time is equal to what we want to change in relation with the Material:
local Lighting = game:GetService("Lighting")
local Part = workspace.Part
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if Lighting.ClockTime == 1200 then --Or 8:00 PM/20:00
--Change Material Here
elseif Lighting.ClockTime == 360 then --Or 6:00 AM/6:00
--Change Material Here
end)
Ok, Thank you for the solution!
Do keep in mind as well that this would only change if the Part’s Material is equal to that specific time hour exactly
If you wanted to check within the range of it, you could probably do something along the lines of checking the ranges between them:
local Lighting = game:GetService("Lighting")
local Part = workspace.Part
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
if Lighting.ClockTime >= 1200 or Lighting.ClockTime <= 360 then --Or 8:00 PM/20:00
--Change Material Here
elseif Lighting.ClockTime >= 360 or Lighting.ClockTime <= 1200 then --Or 6:00 AM/6:00
--Change Material Here
end)
Something along the lines like this I suppose
Ok, Thanks for the information!