Remote Event variables the same

Hello.

Currently I’m using remote events, with 2 args, sender and reason. When done, both of the args are the same.

Local Script:

local players = game:GetService("Players")
local sender = players.LocalPlayer.Name
local reason = script.Parent.Parent.ReportFrame.ReasonText.Text
event:FireServer(sender, reason)

Server Script:

local event = game.ReplicatedStorage.Events.ModCall
local DiscordModule = require(game.ReplicatedStorage.Modules.DiscordModule)

local function ModCall(sender, reason)
DiscordModule:SendReport(sender, reason)
end

event.OnServerEvent:Connect(ModCall)

Module Script:

local DiscordModule = {}

function DiscordModule:SendReport(sender, reason)
	local serverid = game.JobId
	local http = game:GetService("HttpService")
	local webhookid = "no"
	local Data = 
		{
		["content"] = "",
		["embeds"] = {{
			["title"] = "Mod Call",
			["description"] = "",
			["type"] = "rich",
			["color"] = tonumber(0xFF0000),
			["fields"] = {
				{
					["name"] = "Sender",
					["value"] = sender,
					["inline"] = false
				},
				{
					["name"] = "Report",
					["value"] = reason,
					["inline"] = true
				}
			},
		}}
	}
	Data = http:JSONEncode(Data)

	http:PostAsync(webhookid, Data)
end

return DiscordModule

It works, except both the sender and reason variable are the same.
image

Any help would be appreciated.

When you :FireServer() with a remote event, a default “player” parameter is passed. So right now,the value of sender in ModCall() is actually the player. Switch it to ModCall(player, sender, reason)

2 Likes

Oh, thank you very much! I did not know that, nice to know.

@CheekySquid He could remove the sender argument when firing the RemoteEvent and just grab the player’s username from the player parameter. This is also better because exploiters can not just send a random string as the username.

@jufdnhf I recommend adding checks before sending the call to Discord or an exploiter might get your webhook deleted.

1 Like