Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Changing a part's material via script?

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

✓ Accepted answer
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

This discussion is preserved as it was. New answers, comments, and votes are closed.