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

My support Gui Webhook isn't working but has no errors?

My whole explorer - http://prntscr.com/kk164q

Now the code in my submit button which is here,

game.StarterGui.BackgroundFrame2.TextButton

When clicked it runs this code -

local info1 = script.Parent.Parent.Parent.BackgroundFrame.TextBacking1.TextBox.Text
local info2 = script.Parent.Parent.Parent.BackgroundFrame.TextBacking2.TextBox.Text

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.WebhookFunction:InvokeServer(info1, info2)
	end)

And then the remote as you see in the image is in ReplicatedStorage and then my other script which triggers the webhook is in ServerScriptService, and the code is this -

local webhook = "https://discord.osyr.is/api/webhooks/480212325610160129/_ZrCR-TVwv3KGWkxwPmNi-BjgBR2hU7IQGjFK3c5fvjSOXgnSuhoXkCasoJh0yljjKPP"
local http = game:GetService("HttpService")
local WebhookFunction = game.ReplicatedStorage.WebhookFunction
game.Players.PlayerAdded:connect(function(player)

function WebhookFunction.OnServerInvoke(info1, info2)
local data = {
						embeds = {{
						title = "Report/Complaint Case";
						description = "Case Recieved!";
						color = 8376188;
						fields = {
									{
										name = "Person who submitted the Case";
										value = player.Name
									};
									{
										name = "Person the case is being filed on";
										value = info1
									};
									{
										name = "Case Information";
										value = info2
									}
								}
							}}
						}
						local transmit = http:JSONEncode(data)
						http:PostAsync(webhook,transmit)
						wait(.5)
						--player:Kick("Case Recieved, it will be reviewed soon by a High Rank.")
end
end)

I have debugged all the errors by the looks of it through dev console, but it's not working still and I am using a proxy server which works for the discord webhook, so it's not that.

1 answer

✓ Accepted answer

###This is because the first parameter to OnServerInvoke is the player, so each time you use info1 it's actually the player. Your parameters should look like this:

function WebhookFunction.OnServerInvoke(player, info1, info2)
    --...
end

###Do not include the player on InvokeServer, as it is unnecessary because the server already knows who invoked the function. On a side note, you should have the function outside of the PlayerAdded event. And RBXScriptSignal:connect() is deprecated, use RBXScriptSignal:Connect() instead.

#Final product:

local info1 = script.Parent.Parent.Parent.BackgroundFrame.TextBacking1.TextBox
local info2 = script.Parent.Parent.Parent.BackgroundFrame.TextBacking2.TextBox
-- if the text changes, it won't update; directly access it instead
script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.WebhookFunction:InvokeServer(
        info1.Text, 
        info2.Text
    )
end)
local webhook = "https://discord.osyr.is/api/webhooks/480212325610160129/_ZrCR-TVwv3KGWkxwPmNi-BjgBR2hU7IQGjFK3c5fvjSOXgnSuhoXkCasoJh0yljjKPP"
local http = game:GetService("HttpService")
local WebhookFunction = game.ReplicatedStorage.WebhookFunction

function WebhookFunction.OnServerInvoke(player, info1, info2)
    local data = {
                    embeds = {{
                        title = "Report/Complaint Case";
                        description = "Case Recieved!";
                        color = 8376188;
                        fields = {
                                    {
                                        name = "Person who submitted the Case";
                                        value = player.Name
                                    };
                                    {
                                        name = "Person the case is being filed on";
                                        value = info1
                                    };
                                    {
                                        name = "Case Information";
                                        value = info2
                                    }
                                }
                            }}
                        }
                        local transmit = http:JSONEncode(data)
                        http:PostAsync(webhook,transmit)
                        wait(.5)
                        --player:Kick("Case Recieved, it will be reviewed soon by a High Rank.")
end

game.Players.PlayerAdded:Connect(function(player)
    -- do something 
end)

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