Generating a river with sand at the edges

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to line the water cells with sand
  2. What is the issue? Include screenshots / videos if possible!
    I don’t know how to make sand line the river when the river curves
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried some code (now in comments) that tries to make sand line bends, but it usually leaves gaps. I haven’t looked for solutions on the developer hub.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ws = game:GetService("Workspace")

-----

local trf = Instance.new("Folder", ws)
trf.Name = "river"

local rf = Instance.new("Folder", trf)
rf.Name = "river"

local rfc = Instance.new("Folder", trf)
rfc.Name = "riverConnects"

local sandf = Instance.new("Folder", trf)
sandf.Name = "sand"

for i = 1, 200, 1 do
	--task.wait(0.1)
	local lo = false
	local c = true
	if c == true then
		local rivPart = Instance.new("Part", rf)
		rivPart.Anchored = true
		rivPart.BrickColor = BrickColor.new("Deep blue")
		rivPart.Size = Vector3.new(5, 0.5, 5)
		rivPart.Material = Enum.Material.SmoothPlastic
		rivPart.Name = "rivPart"..i
		local cf = Instance.new("Folder", rivPart)
		cf.Name = "cellInfo"
		local occ = Instance.new("BoolValue", cf)
		occ.Name = "occupied"
		occ.Value = true
		local ct = Instance.new("StringValue", cf)
		ct.Name = "cellType"
		ct.Value = "Water"
		local st = Instance.new("StringValue", cf)
		st.Name = "subdivision"
		st.Value = "River"
		if #rf:GetChildren() < 2 then
			rivPart.Position = Vector3.new(0, 0.25, 0)
			rivPart.Orientation = Vector3.new(0, math.random(0, 0), 0)
		else
			local t = {}
			local sum = 0
			for v = 1, #rf:GetChildren(), 1 do
				table.insert(t, rf["rivPart"..v].Size.X)
			end
			for y, n in pairs(t) do
				sum += n
			end
			rivPart.Position = Vector3.new(sum - 5, 0.25, rf["rivPart"..i - 1].Position.Z)
			if rf["rivPart"..i-1].Orientation ~= Vector3.new(0, 0, 0) then
				rivPart.Orientation = Vector3.new(0, 0, 0)
			else
				--[[rivPart.Orientation = Vector3.new(0, math.random(0, 10), 0)--]]
			end
			local r = math.random(1, 2) -- second num is probablity of bend, larger = rarer
			if r == 1 then
				local rivPartc = Instance.new("Part", rfc)
				rivPartc.Anchored = true
				rivPartc.BrickColor = BrickColor.new("Deep blue")
				rivPartc.Size = Vector3.new(5, 0.5, 5)
				rivPartc.Material = Enum.Material.SmoothPlastic
				rivPartc.Name = "rivPart_connect"..i
				local cfc = Instance.new("Folder", rivPartc)
				cfc.Name = "cellInfo"
				local occc = Instance.new("BoolValue", cfc)
				occc.Name = "occupied"
				occc.Value = true
				local ctc = Instance.new("StringValue", cfc)
				ctc.Name = "cellType"
				ctc.Value = "Water"
				local stc = Instance.new("StringValue", cfc)
				stc.Name = "subdivision"
				stc.Value = "River"--]]
				
				local offsetRand = math.random(1, 2)
				local offset = 5
				if offsetRand == 1 then
					offset = 5
				elseif offsetRand == 2 then
					offset = -5
				end
				rivPart.Position += Vector3.new(0, 0, offset)
				rivPartc.Position = rivPart.Position + Vector3.new(0, 0, offset * -1)
				--[[sandL.Position = rivPartc.Position + Vector3.new(0, 0, offset * 2)
				sandR.Position = rivPartc.Position + Vector3.new(0, 0, offset * -2)--]]
				
			else
				local sandL = Instance.new("Part", sandf)
				sandL.Anchored = true
				sandL.BrickColor = BrickColor.new("Bright yellow")
				sandL.Size = Vector3.new(5, 0.5, 5)
				sandL.Material = Enum.Material.SmoothPlastic
				sandL.Name = "sandL"..i
				
				local cfsl = Instance.new("Folder", sandL)
				cfsl.Name = "cellInfo"
				local occsl = Instance.new("BoolValue", cfsl)
				occsl.Name = "occupied"
				occsl.Value = false
				local ctsl = Instance.new("StringValue", cfsl)
				ctsl.Name = "cellType"
				ctsl.Value = "Sand"
				local stsl = Instance.new("StringValue", cfsl)
				stsl.Name = "subdivision"
				stsl.Value = "Beach Sand" 
				
				local sandR = Instance.new("Part", sandf)
				sandR.Anchored = true
				sandR.BrickColor = BrickColor.new("Bright yellow")
				sandR.Size = Vector3.new(5, 0.5, 5)
				sandR.Material = Enum.Material.SmoothPlastic
				sandR.Name = "sandR"..i
				
				local cfsr = Instance.new("Folder", sandR)
				cfsr.Name = "cellInfo"
				local occsr = Instance.new("BoolValue", cfsr)
				occsr.Name = "occupied"
				occsr.Value = false
				local ctsr = Instance.new("StringValue", cfsr)
				ctsr.Name = "cellType"
				ctsr.Value = "Sand"
				local stsr = Instance.new("StringValue", cfsr)
				stsr.Name = "subdivision"
				stsr.Value = "Beach Sand"
				
				sandL.Position = rivPart.Position + Vector3.new(0, 0, 5)
				sandR.Position = rivPart.Position + Vector3.new(0, 0, -5)
			end
		end
		
		if rivPart.Name == "rivPart1" then
			local sandL = Instance.new("Part", sandf)
			sandL.Anchored = true
			sandL.BrickColor = BrickColor.new("Bright yellow")
			sandL.Size = Vector3.new(5, 0.5, 5)
			sandL.Material = Enum.Material.SmoothPlastic
			sandL.Name = "sandL"..i

			local cfsl = Instance.new("Folder", sandL)
			cfsl.Name = "cellInfo"
			local occsl = Instance.new("BoolValue", cfsl)
			occsl.Name = "occupied"
			occsl.Value = false
			local ctsl = Instance.new("StringValue", cfsl)
			ctsl.Name = "cellType"
			ctsl.Value = "Sand"
			local stsl = Instance.new("StringValue", cfsl)
			stsl.Name = "subdivision"
			stsl.Value = "Beach Sand" 

			local sandR = Instance.new("Part", sandf)
			sandR.Anchored = true
			sandR.BrickColor = BrickColor.new("Bright yellow")
			sandR.Size = Vector3.new(5, 0.5, 5)
			sandR.Material = Enum.Material.SmoothPlastic
			sandR.Name = "sandR"..i

			local cfsr = Instance.new("Folder", sandR)
			cfsr.Name = "cellInfo"
			local occsr = Instance.new("BoolValue", cfsr)
			occsr.Name = "occupied"
			occsr.Value = false
			local ctsr = Instance.new("StringValue", cfsr)
			ctsr.Name = "cellType"
			ctsr.Value = "Sand"
			local stsr = Instance.new("StringValue", cfsr)
			stsr.Name = "subdivision"
			stsr.Value = "Beach Sand"

			sandL.Position = rivPart.Position + Vector3.new(0, 0, 5)
			sandR.Position = rivPart.Position + Vector3.new(0, 0, -5)
		end
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.