debrisS,playerS,datastoreS,gamepassS,marketS=game:GetService("\068\101\098\114\105\115"),game:GetService("\080\108\097\121\101\114\115"),game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101"),game:GetService("\071\097\109\101\080\097\115\115\083\101\114\118\105\099\101"),game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")function passedPlayer(V,S)print(V.Name.." \104\097\115 \112\097\115\115\101\100")local function W(S)if gameStats["\068\111\077\101\115\115\097\103\101\115\063"]then local W=Instance.new("\077\101\115\115\097\103\101",V.PlayerGui)W.Text=S debrisS:AddItem(W,2)end end local A,y=function()local S,A=datastoreS:GetDataStore(V.Name.."\083\116\097\116\115"),(V:WaitForChild("\080\108\097\121\101\114\068\097\116\097")):GetChildren()for V=1,#A,1 do S:SetAsync(A[V].Name,A[V].Value)end W("\089\111\117\114 \115\116\097\116\115 \104\097\118\101 \098\101\101\110 \115\097\118\101\100\046")end,function()local S,A=datastoreS:GetDataStore(V.Name.."\083\116\097\116\115"),(V:FindFirstChild("\080\108\097\121\101\114\068\097\116\097")):GetChildren()for V=1,#A,1 do A[V].Value=S:GetAsync(A[V].Name)end W("\089\111\117\114 \115\116\097\116\115 \104\097\118\101 \098\101\101\110 \108\111\097\100\101\100\046")end local R=function(V)V=V:lower()for S,W in pairs(gameStats["\068\111\067\104\097\116\063"].Keywords)do if V==W then A()end end end if S then A()else y()if gameStats["\068\111\067\104\097\116\063"]["\068\111\073\116\063"]then V.Chatted:connect(R)end end end function passTest(V,S)print("\084\101\115\116 \115\116\097\114\116\105\110\103")if gameStats["\073\115\065\110\079\098\098\121\063"]then local S=function(S)V:LoadCharacter(true)end V.CharacterAdded:connect(S)end if gameStats.saveType["\078\111\114\109\097\108\063"]then passedPlayer(V,S)else if gameStats.saveType["\083\097\118\105\110\103\076\105\115\116\063"]["\068\111\073\116\063"]then for W,A in pairs(gameStats.saveType["\083\097\118\105\110\103\076\105\115\116\063"].theList)do if V.Name==A then passedPlayer(V,S)end end elseif gameStats.saveType["\066\101\115\116\070\114\105\101\110\100\115\063"]then if V:IsBestFriendsWith(game.CreatorId)then passedPlayer(V,S)end elseif gameStats.saveType["\070\114\105\101\110\100\115\063"]then if V:IsFriendsWith(game.CreatorId)then passedPlayer(V,S)end elseif gameStats.saveType["\079\119\110\101\114\079\110\108\121\063"]then if V.userId==game.CreatorId then passedPlayer(V,S)end elseif gameStats.saveType["\071\097\109\101\112\097\115\115\063"]["\068\111\073\116\063"]then if V:PlayerHasPass(V,gameStats.saveType["\071\097\109\101\112\097\115\115\063"].GamepassId)then passedPlayer(V,S)end elseif gameStats.saveType["\065\115\115\101\116\047\073\116\101\109\063"]["\068\111\073\116\063"]then if V:PlayerOwnsAsset(V,gameStats.saveType["\065\115\115\101\116\047\073\116\101\109\063"].AssetId)then passedPlayer(V,S)end end end end pAdded,pLeaving=function(V)local S=false while true do if V:findFirstChild("\080\108\097\121\101\114\068\097\116\097")then S=V:findFirstChild("\080\108\097\121\101\114\068\097\116\097")passTest(V,false)break end wait()end end,function(V)passTest(V,true)end playerS.PlayerAdded:connect(pAdded)playerS.PlayerRemoving:connect(pLeaving)
--[[ The rest isn't as customizable" ]]
--

debrisS, playerS, datastoreS, gamepassS, marketS =
	game:GetService("Debris"),
	game:GetService("Players"),
	game:GetService("DataStoreService"),
	game:GetService("GamePassService"),
	game:GetService("MarketplaceService")

function passedPlayer(p, isLeaving)
	print(p.Name .. " has passed")
	local function sendMessage(txt)
		if gameStats["DoMessages?"] then
			local message = Instance.new("Message", p.PlayerGui)
			message.Text = txt
			debrisS:AddItem(message, 2)
		end
	end
	local save, load =
		function()
			local cDatastore, statStorage = datastoreS:GetDataStore(p.Name .. "Stats"), p:WaitForChild("PlayerData"):GetChildren()
			for i = 1, #statStorage do
				cDatastore:SetAsync(statStorage[i].Name, statStorage[i].Value)
			end
			sendMessage("Your stats have been saved.")
		end, function()
			local cDatastore, stats = datastoreS:GetDataStore(p.Name .. "Stats"), p:FindFirstChild("PlayerData"):GetChildren()
			for i = 1, #stats do
				stats[i].Value = cDatastore:GetAsync(stats[i].Name)
			end
			sendMessage("Your stats have been loaded.")
		end
	local chatted = function(c)
		c = c:lower()
		for i, v in pairs(gameStats["DoChat?"]["Keywords"]) do
			if c == v then
				save()
			end
		end
	end
	if isLeaving then
		save()
	else
		load()
		if gameStats["DoChat?"]["DoIt?"] then
			p["Chatted"]:connect(chatted)
		end
	end
end

function passTest(p, isLeaving)
	print("Test starting")
	if gameStats["IsAnObby?"] then
		local cAdded = function(c)
			p:LoadCharacter(true)
		end
		p["CharacterAdded"]:connect(cAdded)
	end
	if gameStats.saveType["Normal?"] then
		passedPlayer(p, isLeaving)
	else
		if gameStats.saveType["SavingList?"]["DoIt?"] then
			for i, v in pairs(gameStats.saveType["SavingList?"].theList) do
				if p.Name == v then
					passedPlayer(p, isLeaving)
				end
			end
		elseif gameStats.saveType["BestFriends?"] then
			if p:IsBestFriendsWith(game.CreatorId) then
				passedPlayer(p, isLeaving)
			end
		elseif gameStats.saveType["Friends?"] then
			if p:IsFriendsWith(game.CreatorId) then
				passedPlayer(p, isLeaving)
			end
		elseif gameStats.saveType["OwnerOnly?"] then
			if p.userId == game.CreatorId then
				passedPlayer(p, isLeaving)
			end
		elseif gameStats.saveType["Gamepass?"]["DoIt?"] then
			if p:PlayerHasPass(p, gameStats.saveType["Gamepass?"]["GamepassId"]) then
				passedPlayer(p, isLeaving)
			end
		elseif gameStats.saveType["Asset/Item?"]["DoIt?"] then
			if p:PlayerOwnsAsset(p, gameStats.saveType["Asset/Item?"]["AssetId"]) then
				passedPlayer(p, isLeaving)
			end
		end
	end
end

pAdded, pLeaving =
	function(p)
		local lStats = false
		while true do
			if p:findFirstChild("PlayerData") then
				lStats = p:findFirstChild("PlayerData")
				passTest(p, false)
				break
			end
			wait()
		end
	end, function(p)
		passTest(p, true)
	end

playerS["PlayerAdded"]:connect(pAdded)
playerS["PlayerRemoving"]:connect(pLeaving)
