Remote Event doesnt use given arguments | Roblox

1k Views Asked by At

client:

local frame = script.Parent.Parent

script.Parent.MouseButton1Down:Connect(function()
    script.Parent.SendReport:FireServer(game.Players.LocalPlayer,script.Parent.Parent.plr.Text, script.Parent.Parent.plr.Text, script.Parent.Parent.text.Text)
end)

server:

local event = script.Parent.SendReport

local function SendReport(plr,reportedu,title,text)
    local Players = game:GetService("Players")
    local http = game:GetService("HttpService")
    local webhook = "webhook link"
    local thumbt = Enum.ThumbnailType.HeadShot
    local thumbs = Enum.ThumbnailSize.Size420x420
    print(plr)
    print(reportedu)
    print(title)
    print(text)
    local se = Players:GetUserThumbnailAsync(plr.UserId,thumbt,thumbs)
    
    local data = {
        ["embeds"] = {{
            ["title"] = "A report has been submitted by " .. plr.Name .. ", for the player: " .. reportedu,
            ["color"] = "000000",
            ["description"] = "**" .. title .. "**" .. "\n\n" .. text,
            ["thumbnail"] = se
        }
        }}
    local finaldata = http:JSONEncode(data)
    http:PostAsync(webhook, finaldata)
end

event.OnServerEvent:Connect(SendReport)

this is what happens when I click the button I tired everything but I couldn't get the text from the right textboxes

https://i.stack.imgur.com/Dqfxu.jpg

1

There are 1 best solutions below

5
Kylaaa On BEST ANSWER

The error is telling you that you are trying to use an Instance like a string. This is caused by the reportedu variable being the LocalPlayer object being a Player and not a string. So you need to stringify the argument somehow. However, I believe that you have made a common mistake with RemoteEvents, and you shouldn't be passing in the LocalPlayer at all.

When you use RemoteEvent:FireServer, the engine automatically adds the player that sent it as the first argument, you don't need to provide it.

For example, if you fire this from the client :

event:FireServer(a, b, c)

The server receives ...

event.OnServerEvent:Connect(function(player, a, b, c) 
    ...
end)

That's why your reportedu variable is the showing up as the LocalPlayer on the server. So to fix this, don't pass in the LocalPlayer on the client.

local frame = script.Parent.Parent
local btn = script.Parent
local event = script.Parent.SendReport

btn.MouseButton1Down:Connect(function()
    local reportedu = frame.plr.Text
    local title = frame.plr.Text
    local text = frame.text.Text
    event:FireServer(reportedu, title, text)
end)