How would I create an infinite water generator?
I currently have this script :
while wait(1/16) do
local RenderWater = workspace:FindFirstChild("RenderWater")
if RenderWater then
workspace.Terrain:FillBlock(RenderWater.CFrame, RenderWater.Size, Enum.Material.Air)
local camera = workspace.CurrentCamera
if camera then
if game.Players.LocalPlayer.Character then
local pos = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
if pos then
RenderWater.CFrame = CFrame.new(pos.CFrame.X, RenderWater.Position.Y, pos.CFrame.Z)
workspace.Terrain:FillBlock(RenderWater.CFrame, RenderWater.Size, Enum.Material.Water)
end
end
end
end
end
The RenderWater
part has a size of 512, 27.6, 512
but I cannot find a way to prevent memory leaks.
Any help is appreciated