"attempt to concatenate string with Instance"

I’m trying to send text via remote events.
The webhook works fine it can send messages, but I have no idea what’s causing the error.
Im trying to make it send all the purchase information that someone made, so we can use it as extra verification that they paid.

Can someone take a look at the code?

game.ReplicatedStorage.PaymentSucessBusFirst.OnClientEvent:Connect(function()
	local check = math.random(300,400)
	local reciept1 = math.random(10000,99999)
	local reciept2 = math.random(100,999)
	script.Parent.text1.Text = "Printing reciept..."
	script.Parent.ProcessingFirst.checkingnumber.Text = ("Checking Number: Ibis " .. check)
	script.Parent.ProcessingFirst.recieptno.Text = ("Reciept " .. reciept1 .. game.Players.LocalPlayer.UserId .. reciept2 .. "110")
	wait(math.random(3,25))
	script.Parent.ProcessingFirst.Visible = true
    -- Code after here is most relevant
    local text = ("New purchase has been made @Renting Place - User and Id:".. game.Players.LocalPlayer.Name .. " " .. game.Players.LocalPlayer.UserId .. " Checking No: Ibis " .. check .. " Reciept No " .. reciept1 .. game.Players.LocalPlayer.UserId .. reciept2 .. "110 Product 110 Building Rent First Time Payment - React with check to confirm payment has been processed")
	game.ReplicatedStorage.SendWebhookmsg:FireServer(text)
end)

The error was at line 6 in this script.

local httpService = game:GetService("HttpService")

game.ReplicatedStorage.SendWebhookmsg.OnServerEvent:Connect(function(text)
	httpService:PostAsync("https://webhook.lewisakura.moe/api/webhooks/(removed id and token)",
		httpService:JSONEncode({
			content = ("Test :" .. text)
		})
	)
end)
1 Like

When it says that it attempts to concentrate string with instance, it means that you put an instance inside of string.

If you want to convert that instance into string, you can use tostring() and convert anything into string.

1 Like

What happens if you don’t have parentheses around the text variable? And yes you should implement tostring() anyway just because exploiters can false fire instances or other things that can’t be concatenated.

Hey, I have implemented tostring

local httpService = game:GetService("HttpService")

game.ReplicatedStorage.SendWebhookmsg.OnServerEvent:Connect(function(text)
	httpService:PostAsync("https://webhook.lewisakura.moe/api/webhooks/",
		httpService:JSONEncode({
			content = ("test " .. tostring(text))
		})
	)
end)

The issue is, its not sending the full message.
Maybe I didn’t implement it well, im kind of new to “tostring”

1 Like

I see…

That’s because the first argument in OnServerEvent is the player who fired the remote, so add a player argument before the text argument.

1 Like

I don’t fully understand what you mean

What I mean is that the text argument is the first argument, which returns the player object.

I also added a sanity check to prevent exploiters. You can modify it

Script:

local httpService = game:GetService("HttpService")

local remoteGate = {}

game.ReplicatedStorage.SendWebhookmsg.OnServerEvent:Connect(function(player, text)
	if remoteGate[player] then
		player:Kick("Remote Spam")
	end
	remoteGate[player] = true
	task.delay(1, function()
		remoteGate[player] = nil
	end)
	httpService:PostAsync("https://webhook.lewisakura.moe/api/webhooks/",
		httpService:JSONEncode({
			content = ("test " .. tostring(text))
		})
	)
end)

is this what you meant?
image

1 Like

updated it with your script and its still the same… i think there’s an issue in the localscript or something.
image

The issue has nothing to do with the local script.

Are you making sure that the message you’re sending is the text argument and not player argument?

uhhh yes, take a look

    local text = ("New purchase has been made @Renting Place - User and Id:".. game.Players.LocalPlayer.Name .. " " .. game.Players.LocalPlayer.UserId .. " Checking No: Ibis " .. check .. " Reciept No " .. reciept1 .. game.Players.LocalPlayer.UserId .. reciept2 .. "110 Product 110 Building Rent First Time Payment - React with check to confirm payment has been processed")
	game.ReplicatedStorage.SendWebhookmsg:FireServer(text)

I meant on the server script. is it tostring(text) instead of tostring(player)?

Yes, it is. Pretty sure about it

Could you do some printings and show the output?

one second, i was able to confirm though that its not with localscript as i tried printing and message is complete. This is what it should send

okay, so it seems like the output was my username… hmmm this is weird
image

Wait a sec. Use this ServerScript.

local httpService = game:GetService("HttpService")

game.ReplicatedStorage.SendWebhookmsg.OnServerEvent:Connect(function(plr, text)
	httpService:PostAsync("https://webhook.lewisakura.moe/api/webhooks/(removed id and token)",
		httpService:JSONEncode({
			content = ("Test :" .. tostring(text))
		})
	)
end)
1 Like

its still the same result… uhhh

Oh wait didn’t know you tried that already. Go back to the other script but print player, then print text. Then print text==player. If the third print says true something’s really wrong.

okay, i just did it. the third one says false so there must be something wrong with the serverscript.