Sending a dictionary from Client to Server

Hello. I am trying to send a dictionary from Client to Server.

Dictionary

local userInputData = {
				['Title'] = level.Text;
				['Username'] = player.Name;
				['Avatar'] = players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420);
				['Answers'] = {
					appFrameData['Answers'][1];
					appFrameData['Answers'][2];
					appFrameData['Answers'][3];
					appFrameData['Answers'][4];
				}
			}

Server

submitEvent.OnServerEvent:Connect(function(player, userInputData, appFrameData)
	local dataToSend = {
		['content'] = '',
		['embeds'] = {
			['title'] = userInputData['Title'],
			['description'] = 'Username: '..userInputData['Username'],
			['color'] = 5661687,
			['footer'] = {
				['icon_url'] = 'https://tr.rbxcdn.com/c379b37e1dc253d6dcab6355c4a2272d/150/150/Image/Png',
				['text'] = 'RECRUITMENT CENTER'
			};
			['thumbnail'] = {
				['url'] = userInputData['Avatar'],
			};
			['author'] = {
				['name'] = 'SCP:F | [APOLLYON]',
				['icon_url'] = 'https://tr.rbxcdn.com/c379b37e1dc253d6dcab6355c4a2272d/150/150/Image/Png',
			};
			['fields'] = {
				{
					['name'] = userInputData['Questions'][1],
					['value'] = userInputData['Answers'][1],
				};
				{
					['name'] = userInputData['Questions'][2],
					['value'] = userInputData['Answers'][2],
				};
				{
					['name'] = userInputData['Questions'][3],
					['value'] = userInputData['Answers'][3],
				};
				{
					['name'] = userInputData['Questions'][4],
					['value'] = userInputData['Answers'][4],
				};
			}
		}
	}
	local finalData = https:JSONEncode(dataToSend)
	https:PostAsync(discordHook, finalData)
end)

Error

Title is not a valid member of Player "Players.Forged3v1MiamiClutch"  -  Server - Server:26
1 Like

exactly which line is line 26? Im not seeing where the issue could be occuring

1 Like

it doesn’t really matter the line as the issue persists whenever I try to access the dictionary called userInputData; line 26 would be ['title'] = userInputData['Title']

1 Like

Can you please show me the code you are using to fire the remote event? I think i know what the issue is

1 Like
			submitButton.MouseButton1Click:Connect(function()
				submitEvent:FireServer(player, userInputData, appFrameData)
			end)
1 Like

Try replacing it with this:

submitButton.MouseButton1Click:Connect(function()
		submitEvent:FireServer(userInputData, appFrameData)
end)

The player variable is automatically passed along, so you sent it as 2 seperate parameters

1 Like

thank you, however now I seem to have found another issue, which is this

['fields'] = {
				{
					['name'] = userInputData['Questions'][1],
					['value'] = userInputData['Answers'][1],
				};
				{
					['name'] = userInputData['Questions'][2],
					['value'] = userInputData['Answers'][2],
				};
				{
					['name'] = userInputData['Questions'][3],
					['value'] = userInputData['Answers'][3],
				};
				{
					['name'] = userInputData['Questions'][4],
					['value'] = userInputData['Answers'][4],
				};
			}

Error: ServerScriptService.Server:42: attempt to index nil with ‘1’ - Server - Server:42

in this:

local userInputData = {
				['Title'] = level.Text;
				['Username'] = player.Name;
				['Avatar'] = players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420);
				['Answers'] = {
					appFrameData['Answers'][1];
					appFrameData['Answers'][2];
					appFrameData['Answers'][3];
					appFrameData['Answers'][4];
				}
		}

You never actually defined what the questions are, on the answers!

1 Like

I don’t know why I’ve been so silly today, literally made some insignificant mistakes, thank you very much again