Where I forgot to put a and "end"?

Hi guys!

The Output always print this error to me:

Where I forgot to put an “end”, or delete an “end”?

Here is the Script
local currencyName = "Money"
local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
game.Players.PlayerAdded:Connect(function(player)

	local folder = Instance.new("Folder")
	folder.Name = "leaderstats"
	folder.Parent = player	
	
	local currency = Instance.new("IntValue")
	currency.Name = currencyName
	currency.Parent = folder

    local fake1 = Instance.new("StringValue")
    fake1.Name = currency.Name
    fake1.Value = tostring(currency.Value)
    fake1.Parent = folder 

    while wait() do
	local x = tostring(currency.Value)
	if #x >10 then -- Billions
		fake1.Value = x:sub(0,(#x-9)).."."..(x:sub(#x-7,(#x-7))).."B+"
	elseif #x >= 7 then -- Millions
		fake1.Value = x:sub(0,(#x-6)).."."..(x:sub(#x-5,(#x-5))).."M+"
	elseif #x >= 4 then -- Thousands
		fake1.Value = x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
	else -- If it's not high enough...
		fake1.Value = tonumber(currency.Value)
	end

	player.CharacterAdded:Connect(function(character)
	character.Humanoid.Died:Connect(function()
		local tag = character.Humanoid:FindFirstChild("creator")
		if tag ~= nil then
			local player = tag.Value
			local bountry = 20
			
			local leaderstats = player:WaitForChild("leaderstats")
			leaderstats.Money.Value = leaderstats.Money.Value + bounty 
			end
		end)
	end)
	
	local ID = currencyName.."-"..player.UserId
	local savedData = nil	
	
	pcall(function()
		savedData = DataStore:GetAsync(ID)
	end)
	
	if savedData ~= nil then
		currency.Value = savedData
		print("Data loaded")
	else
		-- New player
		currency.Value = 100
		print("New player to the game")
	end
end


game.Players.PlayerRemoving:Connect(function(player)
	local ID = currencyName.."-"..player.UserId
	DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end)

game:BindToClose(function()
	
	-- When game is ready to shutdown
	
	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			player:Kick("This game is shutting down")
		end
	end
	
	wait(5)	
	
end)
end

on line 81 you have
end
to close the PlayerAdded function, but it should be end) as its being passed into the Connect method

4 Likes