Small spawner issue

Hi. So everything regarding the spawning works fine except a player cant spawn a vehicle if another player is inside their vehicle.

local PhysicsService = game:GetService("PhysicsService") -- Import the PhysicsService for collision groups
local Gui = script.RespawnGui
local Group = script.Parent.Parent.Parent
local RespPoint = Group.Platform.RespawPoint

-- Ensure collision groups exist for tank and tank parts
if not PhysicsService:CollisionGroupExists("PlayerTank") then
	PhysicsService:CreateCollisionGroup("PlayerTank")
end

-- Function to set all parts of the tank to a specific collision group
local function SetTankCollisionGroup(tankModel, groupName)
	for _, part in pairs(tankModel:GetDescendants()) do
		if part:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(part, groupName)
		end
	end
end

local function SpawnNew(plyr, img, size, color, label)
	-- Check if the player already has a tank using attributes
	if plyr:GetAttribute("HasTank") == true then
		warn(plyr.Name .. " already has a tank. Cannot spawn another one.")
		return -- Exit if the player already has a tank
	end

	script.Parent.Color = Color3.fromRGB(30, 30, 30)
	script.Parent.Parent.Blueprint.Color = Color3.fromRGB(30, 30, 30)
	script.Parent.BillboardGui.Enabled = false
	script.Parent:SetAttribute("CanRespawn", false)

	local newTonk = game.ReplicatedStorage.TankStuff3.Tank:Clone()
	newTonk.Parent = Group -- Parent it to the Group like before
	newTonk.PrimaryPart = newTonk.RespawPoint
	newTonk:SetPrimaryPartCFrame(CFrame.new(RespPoint.Position))
	newTonk:SetPrimaryPartCFrame(CFrame.new(newTonk.RespawPoint.Position, newTonk.RespawPoint.Position + RespPoint.CFrame.LookVector) + Vector3.new(0, 2, 0))
	newTonk.RespawPoint:Destroy()

	-- Assign ownership of the tank to the player
	newTonk:SetAttribute("Owner", plyr.UserId)

	-- Ensure each player's tank has independent parts
	for _, child in pairs(newTonk:GetDescendants()) do
		if child:IsA("BasePart") and (child.Parent.Name == "Color" or child.Name == "Color" or child.Name == "DoorHinge" or child.Name == "FixedAttach" or child.Name == "Connector" or child.Name == "DoorPanel" or child.Name == "Launcher" or child.Name == "MGHinge") then
			child.Color = color
		end
	end

	newTonk.Chassi.Turret.Structure.EmblemPart.SurfaceGui.ImageLabel.Image = img
	newTonk.Chassi.Turret.Structure.EmblemPart.SurfaceGui.ImageLabel.Size = UDim2.new(size, 0, size, 0)
	local filteredMessage = game:GetService("Chat"):FilterStringForBroadcast(label, plyr)
	newTonk.Chassi.Turret.Structure.LabelPart.SurfaceGui.TextLabel.Text = filteredMessage

	-- Set up the tank parts and physics for the player
	local Structure = newTonk.Chassi.Structure
	local Turret = newTonk.Chassi.Turret
	local Wheels = newTonk.Wheels
	local Tracks = newTonk.Tracks

	-- Unanchor parts specific to the player's tank
	wait(1)
	for _, child in pairs(Wheels:GetChildren()) do
		if child.Name == "WheelSusp." then
			child.Connector.Anchored = false
			wait(0.01)
		end
	end

	for _, child in pairs(Tracks.TrackLeft:GetChildren()) do
		child.Anchored = false
	end

	for _, child in pairs(Tracks.TrackRight:GetChildren()) do
		child.Anchored = false
	end

	Structure.qPerfectionWeld.Disabled = false
	wait(0.5)
	Turret.Structure.qPerfectionWeld.Disabled = false
	Turret.Cannon.qPerfectionWeld.Disabled = false

	-- Apply collision group for the tank
	SetTankCollisionGroup(newTonk, "PlayerTank")

	print("respawned tank")

	-- Track that the player has a tank using attributes
	plyr:SetAttribute("HasTank", true)

	-- Make the DeleteVehicle button visible when the tank is spawned
	plyr.PlayerGui.Interface.DeleteVehicle.Visible = true

	-- Connect the delete button to remove the player's tank and related GUI
	plyr.PlayerGui.Interface.DeleteVehicle.MouseButton1Click:Connect(function()
		-- Ensure only the player's own tank is deleted
		for _, tank in pairs(Group:GetChildren()) do
			if tank:GetAttribute("Owner") == plyr.UserId then
				tank:Destroy()
				print("Deleted player's tank")

				-- Hide the DeleteVehicle button
				plyr.PlayerGui.Interface.DeleteVehicle.Visible = false

				-- Destroy all GUI related to the tank system
				if plyr.PlayerGui:FindFirstChild("RespawnGui") then
					plyr.PlayerGui.RespawnGui:Destroy()
				end

				-- Set HasTank to false
				plyr:SetAttribute("HasTank", false)
				break
			end
		end
	end)

	wait(15)
	script.Parent.Color = Color3.fromRGB(162, 158, 147)
	script.Parent.Parent.Blueprint.Color = Color3.fromRGB(162, 158, 147)
	script.Parent.BillboardGui.Enabled = true
	script.Parent:SetAttribute("CanRespawn", true)
end

script.RespawnTankEvent.OnServerEvent:Connect(function(plyr, img, size, color, label)
	-- Each player can now spawn their own tank independently
	SpawnNew(plyr, img, size, color, label)
	print(plyr.Name)
end)

function GiveGui(plyr)
	local newGui = Gui:Clone()
	newGui.Respawner.Value = script.Parent.Parent.Parent
	newGui.Parent = plyr.PlayerGui
	newGui.MainFrame.GeneralScript.Disabled = false

	-- Ensure the GUI is independent for each player
	if not plyr:GetAttribute("HasTankGui") then
		plyr:SetAttribute("HasTankGui", false)
	end
end

script.Parent.Parent.ClickDetector.MouseClick:Connect(function(plyr)
	GiveGui(plyr)
end)

Hope you guys can help!

Actually oops that was an old version of the script. Here is the working version:

local Gui = script.RespawnGui
local Group = script.Parent.Parent.Parent
local RespPoint = Group.Platform.RespawPoint

local function SpawnNew(plyr, img, size, color, label)
    -- Check if the player already has a tank using attributes
    if plyr:GetAttribute("HasTank") == true then
        warn(plyr.Name .. " already has a tank. Cannot spawn another one.")
        return -- Exit if the player already has a tank
    end

    -- Disable spawning temporarily
    script.Parent.Color = Color3.fromRGB(30, 30, 30)
    script.Parent.Parent.Blueprint.Color = Color3.fromRGB(30, 30, 30)
    script.Parent.BillboardGui.Enabled = false
    script.Parent:SetAttribute("CanRespawn", false)

    -- Clone the tank and set its position
    local newTonk = game.ReplicatedStorage.TankStuff3.Tank:Clone()
    newTonk.Parent = Group
    newTonk.PrimaryPart = newTonk.RespawPoint
    newTonk:SetPrimaryPartCFrame(CFrame.new(RespPoint.Position))
    newTonk:SetPrimaryPartCFrame(CFrame.new(newTonk.RespawPoint.Position, newTonk.RespawPoint.Position + RespPoint.CFrame.LookVector) + Vector3.new(0, 2, 0))
    newTonk.RespawPoint:Destroy()

    -- Assign ownership of the tank to the player
    newTonk:SetAttribute("Owner", plyr.UserId)

    -- Customize tank appearance
    for _, child in pairs(newTonk:GetDescendants()) do
        if child:IsA("BasePart") and (child.Parent.Name == "Color" or child.Name == "Color" or child.Name == "DoorHinge" or child.Name == "FixedAttach" or child.Name == "Connector" or child.Name == "DoorPanel" or child.Name == "Launcher" or child.Name == "MGHinge") then
            child.Color = color
        end
    end

    newTonk.Chassi.Turret.Structure.EmblemPart.SurfaceGui.ImageLabel.Image = img
    newTonk.Chassi.Turret.Structure.EmblemPart.SurfaceGui.ImageLabel.Size = UDim2.new(size, 0, size, 0)
    local filteredMessage = game:GetService("Chat"):FilterStringForBroadcast(label, plyr)
    newTonk.Chassi.Turret.Structure.LabelPart.SurfaceGui.TextLabel.Text = filteredMessage

    -- Unanchor parts specific to the player's tank
    wait(1)
    for _, child in pairs(newTonk.Wheels:GetChildren()) do
        if child.Name == "WheelSusp." then
            child.Connector.Anchored = false
            wait(0.01)
        end
    end

    for _, child in pairs(newTonk.Tracks.TrackLeft:GetChildren()) do
        child.Anchored = false
    end

    for _, child in pairs(newTonk.Tracks.TrackRight:GetChildren()) do
        child.Anchored = false
    end

    newTonk.Chassi.Structure.qPerfectionWeld.Disabled = false
    wait(0.5)
    newTonk.Chassi.Turret.Structure.qPerfectionWeld.Disabled = false
    newTonk.Chassi.Turret.Cannon.qPerfectionWeld.Disabled = false

    -- Track that the player has a tank using attributes
    plyr:SetAttribute("HasTank", true)

    -- Make the DeleteVehicle button visible when the tank is spawned
    plyr.PlayerGui.Interface.DeleteVehicle.Visible = true

    -- Connect the delete button to remove the player's tank and related GUI
    plyr.PlayerGui.Interface.DeleteVehicle.MouseButton1Click:Connect(function()
        -- Ensure only the player's own tank is deleted
        for _, tank in pairs(Group:GetChildren()) do
            if tank:GetAttribute("Owner") == plyr.UserId then
                tank:Destroy()
                print("Deleted player's tank")

                -- Hide the DeleteVehicle button
                plyr.PlayerGui.Interface.DeleteVehicle.Visible = false

                -- Destroy all GUI related to the tank system
                if plyr.PlayerGui:FindFirstChild("RespawnGui") then
                    plyr.PlayerGui.RespawnGui:Destroy()
                end

                -- Set HasTank to false
                plyr:SetAttribute("HasTank", false)
                break
            end
        end
    end)

    -- Re-enable spawning after a delay
    wait(15)
    script.Parent.Color = Color3.fromRGB(162, 158, 147)
    script.Parent.Parent.Blueprint.Color = Color3.fromRGB(162, 158, 147)
    script.Parent.BillboardGui.Enabled = true
    script.Parent:SetAttribute("CanRespawn", true)
end

script.RespawnTankEvent.OnServerEvent:Connect(function(plyr, img, size, color, label)
    -- Each player can now spawn their own tank independently
    SpawnNew(plyr, img, size, color, label)
    print(plyr.Name)
end)

function GiveGui(plyr)
    local newGui = Gui:Clone()
    newGui.Respawner.Value = script.Parent.Parent.Parent
    newGui.Parent = plyr.PlayerGui
    newGui.MainFrame.GeneralScript.Disabled = false

    -- Ensure the GUI is independent for each player
    if not plyr:GetAttribute("HasTankGui") then
        plyr:SetAttribute("HasTankGui", false)
    end
end

script.Parent.Parent.ClickDetector.MouseClick:Connect(function(plyr)
    GiveGui(plyr)
end)