Need help with moving terrain water up and down smoothly

I want to achieve: To make water terrain grow up and down smoothly

The issue I have is: Don’t know how to have water terrain go up and down smoothly

The solutions I have tried so far: I haven’t tried anything, since I don’t know what I can do to achieve what I want for this

Here is my code, I added comments and removed some parts to make it easier to understand.

local TweenService = game:GetService("TweenService")

local Valve = script.Parent.Parent:WaitForChild("Meshes/valve2")

local Shutoff = true
local EmitterPart = script.Parent.Parent:WaitForChild("Emitter") -- Part that puts out water particles

function FillTerrain(Region, Resolution, Material)
	game.Workspace.Terrain:FillRegion(Region, Resolution, Material)
end

-- Trigger events --
local RegionPart = script.Parent.Parent:WaitForChild("Region")
local Pos1 = 	RegionPart.Position - (RegionPart.Size / 2)
local Pos2 = RegionPart.Position + (RegionPart.Size / 2)
local Region = Region3.new(Pos1, Pos2)

script.Parent.ProximityPrompt.Triggered:Connect(function()
	if Shutoff == false then
		Shutoff = true 
		FillTerrain(Region, 4, "Air") Removes water from position 
	else
		Shutoff = false 
		EmitterPart["1"].Enabled = true -- Makes water particles active
		wait(4)
		EmitterPart["1"].Enabled = false -- Makes water particles inactive
		FillTerrain(Region, 4, "Water") - Fills position with water
	end
end)

Basically, you use a valve/trigger to add and remove water.

If somebody could just give me a snippet of code or something so I can base it off of that, that would be great. Also, if you can suggest ways to make my current code better that would be great as well.

1 Like

You cannot manipulate terrain with code on runtime. Is there a reason that you need the terrain water to move up and down that can’t be worked around?

You may have to consider moving parts instead of the terrain water. The only way you can edit terrain water on runtime is by using the water properties.

This answered my question, thanks. Also, I used terrain water to be realistic, but I could probably just use textures.

1 Like