local X=require(script.Settings)local N=game:GetService("\082\117\110\083\101\114\118\105\099\101")local K=true function count()local N=0 if X.onlyme then local K=X.owners[1]if game.Players:FindFirstChild(K)then N+=1 else if tonumber(K)~=nil then if game.Players:GetPlayerByUserId(K)then N+=1 end end end else for X,K in pairs(X.owners)do if game.Players:FindFirstChild(K)then N+=1 else if tonumber(K)~=nil then if game.Players:GetPlayerByUserId(K)then N+=1 end end end end end return N end function search(X,N)local K=string.lower(N.Name)if table.find(X,K)or table.find(X,N.UserId)then return true else return false end end game.Players.PlayerAdded:connect(function(N)if search(X.owners,N)then N.Chatted:connect(function(N)if string.lower(N)==string.lower(X.delmsg)then script.Parent:Destroy()elseif string.lower(N)==string.lower(X.carname..(" "..X.unlock))then K=false elseif string.lower(N)==string.lower(X.carname..(" "..X.lock))then K=true end end)end end)wait(2)for N,V in pairs(game.Players:GetChildren())do if search(X.owners,V)then V.Chatted:connect(function(N)if string.lower(N)==string.lower(X.delmsg)then script.Parent:Destroy()elseif string.lower(N)==string.lower(X.carname..(" "..X.unlock))then K=false elseif string.lower(N)==string.lower(X.carname..(" "..X.lock))then K=true end end)end end if N:IsStudio()and X.studioperms then warn("\115\116\117\100\105\111 \100\101\116\101\099\116\101\100\044 \099\097\114 \119\105\108\108 \110\111\116 \108\111\099\107")elseif count()==0 then warn("\110\111 \111\119\110\101\114\115 \102\111\117\110\100\044 \100\101\108\101\116\105\110\103")script.Parent:Destroy()script:Destroy()end game.Players.PlayerRemoving:connect(function(X)if count()==0 then script.Parent:Destroy()end end)script.Parent.DriveSeat.ChildAdded:connect(function(V)if V.Name=="\083\101\097\116\087\101\108\100"then if V.Part1.Name=="\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"then local f=game.Players:GetPlayerFromCharacter(V.Part1.Parent)if search(X.owners,f)or N:IsStudio()and X.studioperms or K==false then else wait()V:Destroy()if X.lethal then f.Character.Humanoid.Health-=f.Character.Humanoid.Health else f:LoadCharacter()end end end end end)
--// SProtect by Itzt: V1.0

local M = require(script.Settings)
local RS = game:GetService("RunService")

local locked = true

function count()
	local z = 0
	if M.onlyme then
		local v = M.owners[1]
		if game.Players:FindFirstChild(v) then
			z += 1
		else
			if tonumber(v) ~= nil then
				if game.Players:GetPlayerByUserId(v) then
					z += 1
				end
			end
		end
	else
		for i, v in pairs(M.owners) do
			if game.Players:FindFirstChild(v) then
				z += 1
			else
				if tonumber(v) ~= nil then
					if game.Players:GetPlayerByUserId(v) then
						z += 1
					end
				end
			end
		end
	end
	return z
end

function search(t, p)
	local x = string.lower(p.Name)
	if table.find(t, x) or table.find(t, p.UserId) then
		return true
	else
		return false
	end
end

game.Players.PlayerAdded:connect(function(x)
	if search(M.owners, x) then
		--print("Owner of car granted permissions")
		x.Chatted:connect(function(z)
			if string.lower(z) == string.lower(M.delmsg) then
				script.Parent:Destroy()
			elseif string.lower(z) == string.lower(M.carname .. " " .. M.unlock) then
				locked = false
			elseif string.lower(z) == string.lower(M.carname .. " " .. M.lock) then
				locked = true
			end
		end)
	end
end)

wait(2)

for i, x in pairs(game.Players:GetChildren()) do
	if search(M.owners, x) then
		--print("Owner of car granted permissions")
		x.Chatted:connect(function(z)
			if string.lower(z) == string.lower(M.delmsg) then
				script.Parent:Destroy()
			elseif string.lower(z) == string.lower(M.carname .. " " .. M.unlock) then
				locked = false
			elseif string.lower(z) == string.lower(M.carname .. " " .. M.lock) then
				locked = true
			end
		end)
	end
end

if RS:IsStudio() and M.studioperms then
	warn("studio detected, car will not lock")
elseif count() == 0 then
	warn("no owners found, deleting")
	script.Parent:Destroy()
	script:Destroy()
end

game.Players.PlayerRemoving:connect(function(x)
	if count() == 0 then
		script.Parent:Destroy()
	end
end)

script.Parent.DriveSeat.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" then
		if child.Part1.Name == "HumanoidRootPart" then
			local x = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			if search(M.owners, x) or (RS:IsStudio() and M.studioperms) or (locked == false) then
			else
				wait() --prevent the car from becoming unusable
				child:Destroy()
				if M.lethal then
					x.Character.Humanoid.Health -= x.Character.Humanoid.Health
				else
					x:LoadCharacter()
				end
			end
		end
	end
end)
