Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

invalid argument #2 (string expected, got Instance), while there is a STRING!!!!?

Hi!

So, this is my script, which is in SSS.


local HTTP = game:GetService("HttpService")
local webhook = "Private"

--local remote = Instance.new("RemoteFunction")
--remote.Name = "SendButtonEvent"
--remote.Parent = game:GetService("ReplicatedStorage")
ServerVersion = game.PlaceVersion

local remote = game.ReplicatedStorage.SendButtonEvent

function SendMessage(player)
	print('OnServerInvoke')
	local TextBox = game.Players[player].PlayerGui.Feedback.Mainframe.Support.Backdrop1.TextBox
	local Message = TextBox.Text
	local avatar, ready = game:GetService("Players"):GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
	local msg = ("**[-Start-]** Server Version: "..ServerVersion.." Message " ..Message)
	local payload = HTTP:JSONEncode({content = msg, username = player.Name.." - (#"..player.UserId..")", avatar_url = avatar})
	HTTP:PostAsync(webhook, payload)
	return("Chat Sent")
end


remote.OnServerEvent:Connect(SendMessage)

And it returns this errorline: 17:50:54.174 - ServerScriptService.SupportBoxRemoteV2:13: invalid argument #2 (string expected, got Instance)

However, the freaking TextBox it should look at, IS THERE!

Why the hell is is printing 'GotInstance'

So, the 'TextBox' is a TextBox inside a Gui. Yes, the "local TextBox = " is right. I want it to find the TextBox, so i can later see what the Text inside TextBox is...

1 comment

0

Try to use the tostring() function.

2 answers

When a string is required but the value is not a string, use the function tostring() Or in your case, Name.

local TextBox = game.Players[player].PlayerGui.Feedback.Mainframe.Support.Backdrop1.TextBox

"player" isn't a string .-. Try "player.Name" instead of just "player" and see if it works.

This discussion is preserved as it was. New answers, comments, and votes are closed.