Hey there! I have a question! So I am making a game with water that rises but how can I make the script below more efficient? I want to so I do not have to type out every single line for each time the water goes up and instead have it like:
while true do
local time = 5
height = +5
local cframe = (-272,height,122.5)
terrain=workspace.Terrain
cframe=CFrame.new(-272, -25.995, 122.5)
size=Vector3.new(2029, 21, 1907)
But I know that that wouldn't work so how can I do it so that the water spawns on the Y axis every 5 seconds by doing +5 to only the Y cframe? Below is my inefficient script!
local time = 5
terrain=workspace.Terrain
cframe=CFrame.new(-272, -25.995, 122.5)
size=Vector3.new(2029, 21, 1907)
terrain:FillBlock(cframe,size,Enum.Material.Water)
wait(time)
terrain=workspace.Terrain
cframe1=CFrame.new(-272, -13.995, 122.5)
size1=Vector3.new(2029, 21, 1907)
terrain:FillBlock(cframe1,size1,Enum.Material.Water)
wait(time)
terrain=workspace.Terrain
cframe1=CFrame.new(-272, -8.995, 122.5)
size1=Vector3.new(2029, 21, 1907)
terrain:FillBlock(cframe1,size1,Enum.Material.Water)
wait(time)
terrain=workspace.Terrain
cframe1=CFrame.new(-272, -0.495, 122.5)
size1=Vector3.new(2029, 21, 1907)
terrain:FillBlock(cframe1,size1,Enum.Material.Water)
wait(time)
terrain=workspace.Terrain
cframe1=CFrame.new(-272, 8.005, 122.5)
size1=Vector3.new(2029, 21, 1907)
terrain:FillBlock(cframe1,size1,Enum.Material.Water)

2 comments
Your first code is literally nothing, it should not work because it will either hang or because their is no "end", it won't work
I made that off of the top of my mind of an example of what I wanted to know how to do. But thank you for your concern.