#Ocean Not registering allining

1 messages · Page 1 of 1 (latest)

random sedge
#

Ive been trying to alling the bones but i cant get it to work

#

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Rs = game:GetService("ReplicatedStorage")
local waveTable = require(Rs.WavesModule)

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

-- Put all my ocean planes in one folder for convenience
local OceanFolder = workspace:WaitForChild("OceanPlanes") -- e.g. a folder containing multiple Plane parts (tells that the planes are the ocean)

local bones = {}
local originalPositions = {}

-- Collect bones from all planes inside OceanFolder
for _, plane in pairs(OceanFolder:GetChildren()) do
if plane:IsA("MeshPart") then -- your ocean planes are MeshParts so the script doesnt confuse it
for _, child in pairs(plane:GetChildren()) do
if child:IsA("Bone") then
table.insert(bones, child)
originalPositions[child] = child.Parent.CFrame:PointToWorldSpace(child.Position)
end
end
end
end

local maxDistance = 400
local activeBones = {}

#

local updateRate = 0.5

task.spawn(function()
while true do
local root = character:FindFirstChild("HumanoidRootPart")
if root then
local playerPos = root.Position
activeBones = {}

        for _, bone in pairs(bones) do
            local originalPos = originalPositions[bone]
            if (playerPos - originalPos).Magnitude <= maxDistance then
                table.insert(activeBones, bone)
            end
        end
    end
    task.wait(updateRate)
end

end)

local fadeDistance = 100 -- how far beyond maxDistance to start shrinking waves so it makes a like curve effect in a way

RunService.RenderStepped:Connect(function()
local time = tick()
local root = character:FindFirstChild("HumanoidRootPart")
if not root then return end

local playerPos = root.Position

for _, bone in pairs(bones) do
    local originalPos = originalPositions[bone]
    local dist = (playerPos - originalPos).Magnitude

    if dist <= maxDistance + fadeDistance then
        local x, z = originalPos.X, originalPos.Z


        local randomOffset = math.sin(x * 0.3 + z * 0.7) * 5
        local phaseOffset = (x + z + randomOffset) * 0.1

        local y = waveTable.GenerateWave(time + phaseOffset, x, z)

        local fade = 1
        if dist > maxDistance then
            fade = 1 - ((dist - maxDistance) / fadeDistance)
        end

        bone.Transform = CFrame.new(0, y * fade, 0)
    end
end

end)

#

------this is the whole script

#

i really dont know what else to do

#

and sometimes when i enter roblox studio test here the oceans dont even work

#

they just stay still

rough seal
#

i can give you some that i found

random sedge
#

sure

#

id love that

#

im not sure if this affects it but i added some lag reducing stuff to the script

#

thatt way only bones that are near u activate

#

and the farther the bones the less they move

rough seal
#

im pretty sure you can just add it into the module

#

give me a minute

random sedge
#

ok

rough seal
#

try this

random sedge
#

ok