Can Someone Help Me Convert This Script?

Can someone help me convert this script so that it works with a plane with bones?

local X,Z = 30,30
local Parts = game.Workspace:FindFirstChild("OceanParts")

if not Parts then
	Parts = Instance.new("Folder")
	Parts.Parent = game.Workspace
	Parts.Name = "OceanParts"
end

local Intensity = 10
local Smoothness = 1000
local Size = 25
local YSize = 35
local YOffset = 20
local Seed = 1
local Speed = 0.5

local function MakePartWithColor(Position)
	local Part = Instance.new("Part", Parts)
	Part.Anchored = true
	Part.Position = Position
	Part.Size = Vector3.new(Size,YSize,Size)
	Part.Color = Color3.fromRGB(87,127,167)
	Part.Material = Enum.Material.Glass
	Part.Reflectance = 1
	Part.Transparency = 0.5
	Part.CastShadow = false
	Part.Name = "OceanBlock"
	Part.CanCollide = false
end

local function Tween(o,d,g)
	local es = Enum.EasingStyle.Linear
	
	game:GetService("TweenService"):Create(o,TweenInfo.new(d,es),g):Play()
end

for x = 1,X do
	for z = 1,Z do
		local Position = Vector3.new(x*Size,YOffset,z*Size)
		MakePartWithColor(Position)
	end
end

local gobackwards = false

while true do
	for i,v:Part in pairs(Parts:GetChildren()) do
		local x,z = v.Position.X,v.Position.Z
		local y = ((math.noise((x+Seed)/Smoothness,(z+Seed)/Smoothness) * Intensity)+YOffset)
		Tween(v,Speed,{Position = Vector3.new(x,y,z)})
	end
	Seed += 1
	wait(Speed/100)
end

The Plane

Search for posts about deformable ocean meshes, or skinned ocean meshes. I’ve seen a few in the past that seem to deal with what you’re asking for.

Sounds like you just need to get rid of the code lines with Parts, and change the while true do loop to move the Position or CFrame of the bones instead of the Parts.

Please don’t tween over 1000 bones every fraction of a second…
Try making it so it only tweens bones within a certain distance. I suggest using some type of spatial partitioning system such as an octree or quadtree. It’ll take some extra work but will give some nice performance benefits

1 Like

All of the tutorials I’ve found are either outdated or don’t fully describe how to create the ocean.

Nevermind I found what I’m looking for! It’s a basic sine wave ocean but tbh idk how to do it any other way