"-- Boat Chest Collector Script
-- Handles boat movement and chest collection logic
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Clean workspace
Workspace.Enemies:ClearAllChildren()
Workspace.Effects:ClearAllChildren()
Workspace.Map.Weather:ClearAllChildren()
Workspace.Map.SeaContent:ClearAllChildren()
-- Initialize variables
local ChestCount = 0
local boatName = player.Name .. "Boat"
local boatCenter = Workspace.Boats[boatName].Center
local sailV = boatCenter.SailV
local teleporting = false
-- Function to weld player to boat
local function weldPlayerToBoat()
local weld = Instance.new("WeldConstraint")
weld.Part0 = humanoidRootPart
weld.Part1 = boatCenter
weld.Parent = humanoidRootPart
-- Position player 30 studs above the center
humanoidRootPart.CFrame = boatCenter.CFrame * CFrame.new(0, 30, 0)
return weld
end
-- Function to unweld player
local function unweldPlayer(weld)
if weld then
weld:Destroy()
end
end
-- Function to teleport player to position with speed
local function teleportWithSpeed(destination, speed)
teleporting = true
local distance = (humanoidRootPart.Position - destination.Position).Magnitude
local travelTime = distance / speed
if travelTime > 0 then
wait(travelTime)
end
humanoidRootPart.CFrame = destination.CFrame
teleporting = false
end
-- Function to find nearest chest
local function findNearestChest()
local chests = Workspace.Map.Temporary:GetChildren()
local nearestChest = nil
local minDistance = 3000
for _, chest in ipairs(chests) do
if chest.Name == "Dark Sealed Chest" then
local distance = (humanoidRootPart.Position - chest.Position).Magnitude
if distance <= 3000 and distance < minDistance then
nearestChest = chest
minDistance = distance
end
end
end
return nearestChest
end
-- Function to collect chest
local function collectChest(chest)
-- Stop boat
sailV.Velocity = Vector3.new(0, 0, 0)
-- Unweld player
local weld = humanoidRootPart:FindFirstChildOfClass("WeldConstraint")
unweldPlayer(weld)
-- Teleport to chest
teleportWithSpeed(chest, 300)
-- Fire carry event
local args = {
"Carry",
chest
}
ReplicatedStorage.RS.Remotes.Misc.Carry:FireServer(unpack(args))
-- Rename chest
chest.Name = "None"
-- Increment chest count
ChestCount = ChestCount + 1
wait(1)
end
-- Function to place chest
local function placeChest()
local destination = Workspace.Boats[boatName]["1"]
teleportWithSpeed(destination, 300)
-- Set player orientation
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position, destination.Position)
wait(0.5)
-- Fire place event
local args = {
"Place"
}
ReplicatedStorage.RS.Remotes.Misc.Carry:FireServer(unpack(args))
wait(1)
end
-- Main loop
local function mainLoop()
-- Initial setup
local weld = weldPlayerToBoat()
sailV.Velocity = Vector3.new(-300, 0, 0)
while true do
if not teleporting then
if ChestCount == 2 then
placeChest()
ChestCount = 0
else
local chest = findNearestChest()
if chest then
collectChest(chest)
else
-- No chest found, return to boat
teleportWithSpeed(boatCenter, math.huge) -- Instant teleport
weld = weldPlayerToBoat()
sailV.Velocity = Vector3.new(-300, 0, 0)
end
end
end
wait(0.1)
end
end
-- Start the script
mainLoop()
" remake me this script but add that after it's clean workspace, it's run this script "local boat = workspace.Boats:FindFirstChild("[PLAYERNAME]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
-- Set the CFrame using Deck position, Keel orientation, and Vector3 offset
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
--// Right
createPart(Vector3.new(10, 3, -40))
createPart(Vector3.new(10, 3, -35))
createPart(Vector3.new(10, 3, -30))
createPart(Vector3.new(10, 3, -25))
createPart(Vector3.new(10, 3, -20))
createPart(Vector3.new(10, 3, -15))
createPart(Vector3.new(10, 3, -10))
createPart(Vector3.new(10, 3, -5))
createPart(Vector3.new(10, 3, 0))
createPart(Vector3.new(10, 3, 5))
createPart(Vector3.new(10, 3, 10))
createPart(Vector3.new(10, 3, 15))
createPart(Vector3.new(10, 3, 20))
createPart(Vector3.new(10, 3, 25))
createPart(Vector3.new(10, 3, 30))
--// Middle
createPart(Vector3.new(0, 3, -40))
createPart(Vector3.new(0, 3, -25))
createPart(Vector3.new(0, 3, -20))
createPart(Vector3.new(0, 3, -15))
createPart(Vector3.new(0, 3, -10))
createPart(Vector3.new(0, 3, -5))
createPart(Vector3.new(0, 3, 0))
createPart(Vector3.new(0, 3, 5))
createPart(Vector3.new(0, 3, 10))
createPart(Vector3.new(0, 3, 15))
createPart(Vector3.new(0, 3, 30))
createPart(Vector3.new(0, 3, 35))
createPart(Vector3.new(0, 3, 40))
createPart(Vector3.new(0, 3, 45))
--// Left
createPart(Vector3.new(-10, 3, -40))
createPart(Vector3.new(-10, 3, -35))
createPart(Vector3.new(-10, 3, -30))
createPart(Vector3.new(-10, 3, -25))
createPart(Vector3.new(-10, 3, -20))
createPart(Vector3.new(-10, 3, -15))
createPart(Vector3.new(-10, 3, -10))
createPart(Vector3.new(-10, 3, -5))
createPart(Vector3.new(-10, 3, 0))
createPart(Vector3.new(-10, 3, 5))
createPart(Vector3.new(-10, 3, 10))
createPart(Vector3.new(-10, 3, 15))
createPart(Vector3.new(-10, 3, 20))
createPart(Vector3.new(-10, 3, 25))
createPart(Vector3.new(-10, 3, 30))"