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

Discord Webhook working in Studio but not in game with no errors?

I have used a bypass from the DevForum to get the webhook working, and I have two scripts, one is a local script which monitors when it's clicked, and invokes a remote function, and then a server script which takes the remote function when invoked and sends a webhook to discord.

Local script -

local validated = false
local remote = game.ReplicatedStorage.rFunction
local message1 = script.Parent.Parent.Parent.BackUI1.TextBox.TextBox.Text
local message2 = script.Parent.Parent.Parent.BackUI1.TextBox.TextBox.Text
local plrname = game.Players.LocalPlayer.Name

script.Parent.MouseButton1Click:Connect(function()
	remote:InvokeServer(message1,message2,plrname)
	script.Parent.TextLabel.Text = "Validating"
	if script.Parent.Parent.Parent.BackUI1.TextBox.TextBox.Text == 'admin' and script.Parent.Parent.Parent.BackUI2.TextBox.TextBox.Text == 'admin' then
		validated = true
		wait(1)
		script.Parent.TextLabel.Text = "Login Successful"
		wait(3)
		script.Parent.Parent.Parent.Parent:Destroy()
	else
		wait(1)
		print("Incorrect login, please try again")
		script.Parent.TextLabel.Text = "Incorrect Login"
		wait(1)
		script.Parent.TextLabel.Text = "Login"
	end
end)

Server script -

local hs = game:GetService("HttpService")
local webhook = "https://discord.osyr.is/api/webhooks/477266426655145984/VG3v-PM__-uvEw9k4tuJ7xQGRBuVdIFQFfn_xn-1V4kqygTK0-KQjc56I5HZR2s8A8EH"
local remote = game.ReplicatedStorage.rFunction

function remote.OnServerInvoke(message1,message2,plrname)
	local dat = {
						embeds = {{
						title = "Login Attempted";
						description = "Login System - Login Attempt Logged";
						color = 14908028;
						fields = {
									{
										name = "The User";
										value = plrname.." ("..game.Players.LocalPlayer.UserId..")"
									};
									{
										name = "Username Used";
										value = message1
									};
									{
										name = "Password Used";
										value = message2
									}
								}
							}}
						}
						hs:PostAsync(webhook, dat)
end

I don't know what's wrong with the code, I have searched many times for it and came to no avail of why its working in Studio but not in game.

Also here is a picture of the webhook when used in Studio. http://prntscr.com/kh34qw

1 answer

✓ Accepted answer

In your Server Script you're using LocalPlayer which is for Local Scripts only.

OnServerInvoke actually gets the client who fired the event in the first argument.

function remote.OnServerInvoke(client, message1,message2,plrname)
	...
end

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