How can I make a script that similar to a light script that turn on at night but for material? Can somebody help me?
✓ ANSWER ACCEPTED
How Can I Make A Script For Material Like Grass To Appear Only At Night Time?
1 answer
✓ Accepted answer
This should work. string.sub() subdivides the string. parameter 1 = string, parameter 2 = first position, parameter 3 = second position (defaults at the length of the string).
local part = game.Workspace.Part
while true do
wait(1)
local l = game.Lighting
local h = string.sub(l.TimeOfDay,1,2)
if h < 6 or h >= 18 and part.Material ~= "Grass" then
part.Material = "Grass"
elseif h >= 6 or < 18 and part.Material == "Grass" then
part.Material = "Plastic"
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
