Attempt to concatenate nil with string line 33

I was making a memory script and when I do the command it gives me the error shown in the title.

My Script:

Players = game:GetService("Players")
RS = game:GetService("ReplicatedStorage")

local cmd = "/memory "

function runFilter(msg, uid)
	local ftr = game:GetService("TextService"):FilterStringAsync(msg, uid)
	if ftr then
		return ftr:GetNonChatStringForUserAsync()
	end
	return ""
end

Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(message)
		local tp = player.data.tp.Value
		
		if tp == 0 then
			return
		end
		
		if string.match(message, cmd) then
			local split = string.split(message, cmd)
			local msg = split[2]
			if msg then
				local log = RS.Memories:FindFirstChild(tp)
				if not log then
					log = Instance.new("StringValue")
					log.Parent = RS.Memories
					log.Name = tp
				end
				local success, emsg, fmsg = pcall(runFilter, msg, player.UserId)
				log.Value = ""..fmsg.."\n-"..player.Name
				print("New memory in "..tp..": "..fmsg)
			end
		end
	end)
end)

This is because you attempt to create three variables from pcall, which only returns 2 values. The first being: a boolean based on whether it was successful, and the second being the actual return data. If the function errored, the 2nd variable will be the error message, otherwise it will be the rest of the data.

You can learn more about pcall below:

pcall()

I hope this helps!

So I am not really good at pcall could you give me an alternative script so I can fix this?

On this line, change it to local success, data = pcall(runFilter, msg, player.UserId), and then on the proceeding line change it to log.Value = ""..data.."\n-"..player.Name.

I hope this helps!