Hello!
I am making a gradual terrain color change script for terrain which changes depending on the time, and I can’t wrap my head around what to put in the script. What’s the most optimal and smooth script possible?
Thanks,
R3M1X
Hello!
I am making a gradual terrain color change script for terrain which changes depending on the time, and I can’t wrap my head around what to put in the script. What’s the most optimal and smooth script possible?
Thanks,
R3M1X
All right so the functions you’ll need to use are SetMaterialColor and GetMaterialColor. You can also use a Color3Value object and the GetPropertyChangedSignal method for this type of effect. Here’s an example of how it should all look like:
local terrain = game.Workspace.Terrain
local colorValue = Instance.new("Color3Value")
colorValue.Value = terrain:GetMaterialColor("Grass")
colorValue.Parent = script.Parent
colorValue:GetPropertyChangedSignal("Value"):Connect(function()
terrain:SetMaterialColor("Grass", colorValue.Value)
end)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local tween = game:GetService("TweenService"):Create(colorValue, tweenInfo, {Value = Color3.fromRGB(0, 0, 0)})
tween:Play()
There are most likely other ways of going about this but this is the first to come to my mind.
make sure to use Color3.fromRGB cause it can turn to black instantly instead of tweening.
Thank you. I didn’t use it because I intended for the color to be black. Still appreciated.
You can also divide each number in the parameter by 255 as an alternative like so: Color3.new(0/255, 0/255, 0/255)
I have it working now. Thanks for all of your help. Have a nice day