JIT
fixing boat movement script for chest detection in roblox
"local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local hrp = character:WaitForChild("HumanoidRootPart") local RunService = game:GetService("RunService") local RS = ReplicatedStorage:WaitForChild("RS") local MiscRemotes = RS:WaitForChild("Remotes"):WaitForChild("Misc") -- Step 1: Clear workspace pcall(function() workspace:FindFirstChild("Effects"):Destroy() end) pcall(function() workspace:FindFirstChild("Enemies"):Destroy() end) pcall(function() workspace:FindFirstChild("Map"):FindFirstChild("Weather"):Destroy() end) -- Step 2: Create parts local boat = workspace.Boats:FindFirstChild(player.Name .. "Boat") local deck = boat:FindFirstChild("Deck") local keel = boat:FindFirstChild("Picture2") -- assuming this is keel local partCounter = 0 local function createPart(offset) partCounter += 1 local part = Instance.new("Part") part.Name = tostring(partCounter) part.Size = Vector3.new(1, 1, 1) part.Anchored = false part.CanCollide = false part.CFrame = CFrame.new(deck.Position) * CFrame.Angles( math.rad(keel.Orientation.X), math.rad(keel.Orientation.Y), math.rad(keel.Orientation.Z) ) * CFrame.new(offset) part.Parent = boat local weld = Instance.new("WeldConstraint") weld.Part0 = part weld.Part1 = deck weld.Parent = part end local function createParts() local rightZ = {-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30} local middleZ = {-40, -25, -20, -15, -10, -5, 0, 5, 10, 15, 30, 35, 40, 45} local leftZ = {-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30} for _, z in ipairs(rightZ) do createPart(Vector3.new(10, 2.5, z)) end for _, z in ipairs(middleZ) do createPart(Vector3.new(0, 2.5, z)) end for _, z in ipairs(leftZ) do createPart(Vector3.new(-10, 2.5, z)) end end createParts() -- Step 3: Fly and noclip workspace.Gravity = 0 if floatGyro then floatGyro:Destroy() end if floatVelocity then floatVelocity:Destroy() end floatGyro = Instance.new("BodyGyro") floatGyro.MaxTorque = Vector3.new(1e6, 1e6, 1e6) floatGyro.P = 1e4 floatGyro.CFrame = hrp.CFrame floatGyro.Parent = hrp floatVelocity = Instance.new("BodyVelocity") floatVelocity.MaxForce = Vector3.new(1e6, 1e6, 1e6) floatVelocity.Velocity = Vector3.new(0, 0, 0) floatVelocity.Parent = hrp RunService.Stepped:Connect(function() for _, v in ipairs(character:GetDescendants()) do if v:IsA("BasePart") then v.CanCollide = false end end if floatGyro and hrp then floatGyro.CFrame = hrp.CFrame end end) -- Step 4: Teleport loop local teleportEnabled = true local teleportLoopRunning = false local function teleportLoop() teleportLoopRunning = true while teleportEnabled do local center = boat:FindFirstChild("Center") if center then hrp.CFrame = CFrame.new(center.Position + Vector3.new(0, 30, 0)) end task.wait(3) end teleportLoopRunning = false end -- Step 5: Move/Stop Boat local moveBoatEnabled = true local function moveBoat() local sail = boat.Center:FindFirstChild("SailV") if sail then sail.Velocity = Vector3.new(-200, 0, 0) end end local function stopBoat() local sail = boat.Center:FindFirstChild("SailV") if sail then sail.Velocity = Vector3.new(0, 0, 0) end end -- Step 6: Enable teleport and move task.spawn(teleportLoop) moveBoat() -- Step 7-10: Chest detection and interaction local function getNearestChest() local closest, closestDist = nil, math.huge for _, chest in pairs(workspace:FindFirstChild("Map"):FindFirstChild("Temporary"):GetChildren()) do if chest.Name == "Dark Sealed Chest" and not (chest:FindFirstChild("Weld") or chest:FindFirstChild("BoatWeld")) then local dist = (hrp.Position - chest.Position).Magnitude if dist < 3000 and dist < closestDist then closest = chest closestDist = dist end end end return closest, closestDist end local chestCount = 1 local function handleChest() while true do local chest, dist = getNearestChest() if chest then teleportEnabled = false moveBoatEnabled = false stopBoat() task.wait(dist / 300) hrp.CFrame = CFrame.new(chest.Position + Vector3.new(0, 5, 0)) * CFrame.Angles(0, math.rad(180), 0) task.wait(0.5) MiscRemotes:WaitForChild("Carry"):FireServer("Carry", chest) task.wait(1) local carrying = workspace:FindFirstChild(player.Name):FindFirstChild("Carrying2") if carrying then local dropPart = boat:FindFirstChild(tostring(chestCount)) if dropPart then hrp.CFrame = CFrame.new(dropPart.Position) * CFrame.Angles( math.rad(keel.Orientation.X), math.rad(keel.Orientation.Y), math.rad(keel.Orientation.Z) ) end boat.Center.Anchored = true task.wait(0.5) MiscRemotes:WaitForChild("Carry"):FireServer("Place") chestCount += 1 task.wait(1) boat.Center.Anchored = false end else if not teleportEnabled then teleportEnabled = true moveBoatEnabled = true moveBoat() -- This ensures the sail velocity is set back to -200, 0, 0 if not teleportLoopRunning then task.spawn(teleportLoop) end end end task.wait(2) end end task.spawn(handleChest) " remake me this script, but fix me that after No Dark Sealed Chest found it's don't set back SailV.Velocity to -200, 0, 0 (Tips: try to make that when BoatMover = true then it's constantly set SailV.Velocity to -200, 0, 0 and if BoatMover = false then it's constantly set SailV.Velocity to 0, 0, 0)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidPart")
local RunService = game:GetService("RunService")
local RS = ReplicatedStorage:WaitForChild("RS")
local MiscRemote = RS:WaitForChild("Remote"):WaitForChild("Misc")

-- Clear workspace
pcall(function() workspace:FindFirstChild("Effects"):Destroy() end)
pcall(function() workspace:FindFirstChild("Enemy"):Destroy() end)
pcall(function() workspace:FindFirstChild("Map"):FindFirstChild("Weather"):Destroy() end)

-- Boat setup
local boat = workspace.Boats:FindFirstChild(player.Name.."Boat")
local deck = boat:FindFirstChild("Deck")
local keel = boat:FindFirstChild("Picture2")
local partCounter = 0

local function createPart(offset)
    partCounter += 1
    local part = Instance.new("Part")
    part.Name = tostring(partCounter)
    part.Size = Vector3.new(1,1,1)
    part.Anchored = false
    part.CanCollide = false
    part.CFrame = CFrame.new(deck.Position) * CFrame.Angles(
        math.rad(keel.Orientation.X),
        math.rad(keel.Orientation.Y),
        math.rad(keel.Orientation.Z)
    ) * CFrame.new(offset)
    part.Parent = boat

    local weld = Instance.new("WeldConstraint")
    weld.Part0 = part
    weld.Part1 = deck
    weld.Parent = part
end

local function createParts()
    local rightZ = {-40,-35,-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30}
    local middleZ = {-40,-25,-20,-15,-10,-5,0,5,10,15,30,35,40,45}
    local leftZ = {-40,-35,-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30}

    for _,z in ipairs(rightZ) do createPart(Vector3.new(10,2.5,z)) end
    for _,z in ipairs(middleZ) do createPart(Vector3.new(0,2.5,z)) end
    for _,z in ipairs(leftZ) do createPart(Vector3.new(-10,2.5,z)) end
end

createParts()

-- Flight and noclip
workspace.Gravity = 0

if floatGyro then floatGyro:Destroy() end
if floatVelocity then floatVelocity:Destroy() end

floatGyro = Instance.new("BodyGyro")
floatGyro.MaxTorque = Vector3.new(1e6,1e6,1e6)
floatGyro.P = 1e4
floatGyro.CFrame = hrp.CFrame
floatGyro.Parent = hrp

floatVelocity = Instance.new("BodyVelocity")
floatVelocity.MaxForce = Vector3.new(1e6,1e6,1e6)
floatVelocity.Velocity = Vector3.new(0,0,0)
floatVelocity.Parent = hrp

RunService.Stepped:Connect(function()
    for _,v in ipairs(character:GetDescendants()) do
        if v:IsA("BasePart") then
            v.CanCollide = false
        end
    end

    if floatGyro and hrp then
        floatGyro.CFrame = hrp.CFrame
    end
end)

-- Boat movement control
local boatMover = true
local sailVelocity = Vector3.new(-200,0,0)

local function updateSailVelocity()
    local sail = boat.Center:FindFirstChild("SailV")
    if sail then
        sail.Velocity = boatMover and sailVelocity or Vector3.new(0,0,0)
    end
end

local function moveBoat()
    boatMover = true
    updateSailVelocity()
end

local function stopBoat()
    boatMover = false
    updateSailVelocity()
end

-- Teleport loop
local teleportEnabled = true
local teleportLoopRunning = false

local function teleportLoop()
    teleportLoopRunning = true
    while teleportEnabled do
        local center = boat:FindFirstChild("Center")
        if center then
            hrp.CFrame = CFrame.new(center.Position + Vector3.new(0,30,0))
        end
        task.wait(3)
    end
    teleportLoopRunning = false
end

-- Chest handling
local function getNearestChest()
    local closest, closestDist = nil, math.huge
    for _,chest in ipairs(workspace:FindFirstChild("Map"):FindFirstChild("Temporary"):GetChildren()) do
        if chest.Name == "Dark Sealed Chest" and not (chest:FindFirstChild("Weld") or chest:FindFirstChild("BoatWeld")) then
            local dist = (hrp.Position - chest.Position).Magnitude
            if dist < 3000 and dist < closestDist then
                closest = chest
                closestDist = dist
            end
        end
    end
    return closest, closestDist
end

local chestCount = 1

local function handleChest()
    while true do
        local chest, dist = getNearestChest()
        if chest then
            teleportEnabled = false
            stopBoat()

            task.wait(dist/300)
            hrp.CFrame = CFrame.new(chest.Position + Vector3.new(0,5,0)) * CFrame.Angles(0,math.rad(180),0)
            task.wait(0.5)

            MiscRemote:WaitForChild("Carry"):Fire("Carry", chest)
            task.wait(1)

            local carrying = workspace:FindFirstChild(player.Name):FindFirstChild("Carrying2")
            if carrying then
                local dropPart = boat:FindFirstChild(tostring(chestCount))
                if dropPart then
                    hrp.CFrame = CFrame.new(dropPart.Position) * CFrame.Angles(
                        math.rad(keel.Orientation.X),
                        math.rad(keel.Orientation.Y),
                        math.rad(keel.Orientation.Z)
                    )
                end
                
                boat.Center.Anchored = true
                task.wait(0.5)
                MiscRemote:WaitForChild("Carry"):Fire("Place")
                chestCount += 1
                task.wait(1)
                boat.Center.Anchored = false
            end
        else
            if not teleportEnabled then
                teleportEnabled = true
                moveBoat()
                if not teleportLoopRunning then
                    task.spawn(teleportLoop)
                end
            end
        end
        task.wait(2)
    end
end

-- Initialize
task.spawn(teleportLoop)
moveBoat()
task.spawn(handleChest)

-- Continuous sail velocity update
RunService.Heartbeat:Connect(updateSailVelocity)
```_
Preview not available