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

How Can I Make A Script For Material Like Grass To Appear Only At Night Time?

Asked by
ImfaoXD 158
8 years ago

How can I make a script that similar to a light script that turn on at night but for material? Can somebody help me?

1 answer

Log in to vote
0
Answered by 8 years ago

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
Ad

Answer this question