Owner only vehicle

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to add a part to my script where when the player spawns the car in that they own with a button GUI, no one else can drive that car.
  2. What is the issue? Include screenshots / videos if possible!
    I’m struggling to find solutions to the issue and I have no idea how to start the addition to the script.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried many videos and I’ve looked on the DevHub.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

I have two scripts.

This is a script I found online for the owner only seat.

seat = script.Parent
owner = script.Parent.owner.Value

seat.Changed:Connect(function(plr)
	if seat.Occupant then
		if not seat.Occupand.Name == owner then
			local humanoid = seat.Occupant
			if humanoid then
				local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
				if player then
					seat:SetNetworkOwner(player)
					seat.Occupant.Jump = true
				end
			end
		end
	end
end)

This is the script from one of the buttons when the user spawns the car.

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = game.ReplicatedStorage:WaitForChild("SpawnCar")
local DeleteCarEvent = game.ReplicatedStorage:WaitForChild("DeleteCar")
local CarParams = game.ReplicatedStorage:WaitForChild("GetCarParams"):InvokeServer(script.Parent.Name)
local carName = script.Parent.Name
local SpawnCarFrame = script.Parent.Parent

script.Parent.CarName.Text = CarParams.Name

script.Parent.MouseButton1Down:Connect(function()
	SpawnCarFrame.Visible = false
	local CurrentCar = game.Workspace:FindFirstChild(player.Name .. "sCar")
	if not CurrentCar then
		SpawnCarEvent:FireServer(carName)
	else
		for i, v in pairs(CurrentCar:GetDescendants()) do
			if v:IsA("VehicleSeat") or v:IsA("Seat") then
				if v.Occupant and v.Occupant:IsA("Humanoid") then
					v.Occupant.Sit = false
				end
			end
		end
		wait()
		DeleteCarEvent:FireServer(CurrentCar)
		SpawnCarEvent:FireServer(carName)
	end
end)

I just want to make it so it automatically detects the owner of the vehicle when they spawn it in.
Thank you.

Can you share the contents of where this event is handled on the server? SpawnCarEvent:FireServer(carName)

SpawnCarEvent is in ReplicatedStorage.