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

Changing a part's material via script?

Asked by 8 years ago

What I'm trying to do is when the MinutesAfterMidnight is between 360 and 1140 the material is Plastic, but when it is between 1140 and 360 it is neon.

game.Lighting.LightingChanged:connect(function()
    local tam = game.Lighting:GetMinutesAfterMidnight()
    if tam >= 360 and tam <= 1140 then -- If it's between 06:00:00 and 19:00:00
        script.Parent.PointLight.Enabled = false
        script.Parent.Material = Enum.Material.Plastic
    else -- If it's between 19:00:00 and 06:00:00
        script.Parent.PointLight.Enabled = true
        script.Parent.Material = Enum.Material.Neon
    end
end)

1 answer

Log in to vote
-2
Answered by
Prioxis 673 Moderation Voter
8 years ago
game.Lighting.LightingChanged:connect(function()
    local tam = game.Lighting:GetMinutesAfterMidnight()
    if tam >= 360 and tam <= 1140 then -- If it's between 06:00:00 and 19:00:00
        script.Parent.PointLight.Enabled = false
        script.Parent.Material = Enum.Material.Plastic
    elseif tam <= 359 and tam <= 1139 then
        script.Parent.PointLight.Enabled = true
        script.Parent.Material = Enum.Material.Neon
    else
        print'No requirements have been met.'
    end
end)

This should work basically it checks for the opposite if those two requirements aren't met and if for some odd reason then it will print that.. Hope this works.

Edit : I think I see the issue

Ad

Answer this question