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.