--// SERVICES local Players = game:GetService("Players") local RunService = game:GetService("RunService") local Player = Players.LocalPlayer local ShipsFolder = workspace:WaitForChild("Ships") --// STATE local CurrentShip = nil local Cannons = {} local Connections = {} local Running = true local MAX_DISTANCE = 1e9 --// VALID CANNON NAMES local VALID_CANNONS = { NormalCannon = true, GildedCannon = true, SnowCannon = true, FireCannon = true } --// GUI local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "ShipCannonGui" ScreenGui.ResetOnSpawn = false ScreenGui.Parent = Player:WaitForChild("PlayerGui") local Frame = Instance.new("Frame") Frame.Size = UDim2.new(0, 320, 0, 190) Frame.Position = UDim2.new(0.5, -160, 0.75, 0) Frame.BackgroundColor3 = Color3.fromRGB(25, 25, 25) Frame.BorderSizePixel = 0 Frame.Parent = ScreenGui Instance.new("UICorner", Frame).CornerRadius = UDim.new(0, 12) local function makeLabel(text, y, h, bold) local l = Instance.new("TextLabel") l.Size = UDim2.new(1, -20, 0, h) l.Position = UDim2.new(0, 10, 0, y) l.BackgroundTransparency = 1 l.TextColor3 = Color3.new(1,1,1) l.TextScaled = true l.Font = bold and Enum.Font.GothamBold or Enum.Font.Gotham l.Text = text l.Parent = Frame return l end local ShipLabel = makeLabel("Ship: None", 10, 40, true) local CannonLabel = makeLabel("Cannons: 0", 55, 30, false) CannonLabel.TextColor3 = Color3.fromRGB(200,200,200) local FireButton = Instance.new("TextButton") FireButton.Size = UDim2.new(1, -40, 0, 40) FireButton.Position = UDim2.new(0, 20, 0, 95) FireButton.BackgroundColor3 = Color3.fromRGB(170, 50, 50) FireButton.TextColor3 = Color3.new(1,1,1) FireButton.TextScaled = true FireButton.Font = Enum.Font.GothamBold FireButton.Text = "FIRE" FireButton.Parent = Frame Instance.new("UICorner", FireButton).CornerRadius = UDim.new(0, 10) local UnloadButton = Instance.new("TextButton") UnloadButton.Size = UDim2.new(1, -40, 0, 35) UnloadButton.Position = UDim2.new(0, 20, 0, 145) UnloadButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60) UnloadButton.TextColor3 = Color3.new(1,1,1) UnloadButton.TextScaled = true UnloadButton.Font = Enum.Font.Gotham UnloadButton.Text = "UNLOAD" UnloadButton.Parent = Frame Instance.new("UICorner", UnloadButton).CornerRadius = UDim.new(0, 8) --// FUNCTIONS local function getShipFromSeat(seat) if not seat then return end local model = seat:FindFirstAncestorOfClass("Model") if model and model.Parent == ShipsFolder then return model end end -- Walk up parents to see if this ClickDetector belongs to a valid cannon local function isValidCannon(clickDetector) local parent = clickDetector.Parent while parent and parent ~= workspace do if VALID_CANNONS[parent.Name] then return true end parent = parent.Parent end return false end -- Scan ship for cannons local function scanCannons(ship) Cannons = {} for _, obj in ipairs(ship:GetDescendants()) do if obj:IsA("ClickDetector") and isValidCannon(obj) then table.insert(Cannons, obj) end end CannonLabel.Text = "Cannons: " .. #Cannons end -- Remove destroyed cannons local function cleanCannons() for i = #Cannons, 1, -1 do local cd = Cannons[i] if not cd or not cd.Parent then table.remove(Cannons, i) end end CannonLabel.Text = "Cannons: " .. #Cannons end -- Update current ship local function updateShip() if not Running then return end local char = Player.Character if not char then return end local hum = char:FindFirstChildOfClass("Humanoid") if not hum then return end local seat = hum.SeatPart if seat and seat:IsA("VehicleSeat") then local ship = getShipFromSeat(seat) if ship and ship ~= CurrentShip then CurrentShip = ship ShipLabel.Text = "Ship: " .. ship.Name scanCannons(ship) end else CurrentShip = nil Cannons = {} ShipLabel.Text = "Ship: None" CannonLabel.Text = "Cannons: 0" end cleanCannons() end --// CONNECTIONS table.insert(Connections, FireButton.MouseButton1Click:Connect(function() cleanCannons() for _, detector in ipairs(Cannons) do pcall(function() detector.MaxActivationDistance = MAX_DISTANCE fireclickdetector(detector) end) end end) ) table.insert(Connections, RunService.Heartbeat:Connect(updateShip) ) --// UNLOAD UnloadButton.MouseButton1Click:Connect(function() Running = false for _, c in ipairs(Connections) do pcall(function() c:Disconnect() end) end Cannons = {} CurrentShip = nil if ScreenGui then ScreenGui:Destroy() end end)