All table values inside one string

I want to achieve something that allows me to put all values inside a table into one string, the problem with this is that i can’t find any answer on how to do it, recently i tried to detect if a RemoteEvent has been fired to the server and print out its arguments, it does print out every argument but also creates everytime a new print for each argument that has been fired to the server.

Localscript:

local RemoteEvent = game:GetService("Chat"):WaitForChild("RemoteEvent")
RemoteEvent:FireServer("Value1","Value2","Value3","Value4","Value5","Value6","Value7","Value8","Value9")

Server script:

for _,Event in ipairs(game:GetDescendants()) do
	pcall(function()
		if Event:IsA("RemoteEvent") then
			Event.OnServerEvent:Connect(function(Player,...)
				local Arguments = {...}
				for _,Args in ipairs(Arguments) do
					print("RemoteEvent arguments:",Args)
				end
			end)
		end
	end)
end

As seen here, it creates a new print for each value:
image

But i am trying to achieve this:

A single print for every value inside the arguments table

1 Like
for _,Event in ipairs(game:GetDescendants()) do
	pcall(function()
		if Event:IsA("RemoteEvent") then
			Event.OnServerEvent:Connect(function(Player,...)
				local Arguments = {...}
				local ArgumentString = ""
				for i,Args in ipairs(Arguments) do
					ArgumentString = ArgumentString .. (i > 1 and ", " or " ") .. tostring(Args)
				end
				print("RemoteEvent arguments:",ArgumentString)
			end)
		end
	end)
end

Try that. Should even be nicely formatted, I think.

2 Likes