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)
It must be height = height + 5
, since height = +5
is undefined on what number you're adding 5 to.
You can also just do while wait(time) do
to make it go every 5 seconds.
The following code below should do the trick.
local time = 5 local terrain = workspace.Terrain local height = 0 while wait(time) do height = height + 5 cframe=CFrame.new(-272, -25.995+height, 122.5) size=Vector3.new(2029, 21, 1907) terrain:FillBlock(cframe,size,Enum.Material.Water) end
~SkeletalReality