local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvents = replicatedStorage:FindFirstChild("RemoteEvents")
local serverStorage = game:GetService("ServerStorage")
local serverScriptService = game:GetService("ServerScriptService")
local PhysicsService = game:GetService("PhysicsService")
local playerSetup = serverScriptService:FindFirstChild("PlayerSetup")
local modules = playerSetup.Modules
local logModule = modules.Log
local boatToSpawn
local isBoat
local GroupName = "BoatCollision"
PhysicsService:CreateCollisionGroup(GroupName)
PhysicsService:CollisionGroupSetCollidable(GroupName, GroupName, false)
local function SetCollisionGroup(Part)
if Part:IsA("BasePart") or Part:IsA("Part") then
PhysicsService:SetPartCollisionGroup(Part, "BoatCollision")
end
end
remoteEvents.SpawnBoat.OnServerEvent:Connect(function(player)
isBoat = workspace:FindFirstChild(player.Name .. " Boat")
if isBoat then
isBoat:Destroy()
end
boatToSpawn = serverStorage.Boat:Clone()
boatToSpawn.Name = player.Name .. " Boat"
for _,Object in pairs(boatToSpawn:GetChildren()) do
SetCollisionGroup(Object)
end
boatToSpawn.Parent = workspace
end)
This is the code I’m using. I set CollisionGroups to hopefully prevent any other boats from colliding (basically like, they are CanCollide false so you cant just run them over)
This boat is 2-seated, so it’s not a local boat.