Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I keep getting this error when executing my remote event. What did I do wrong?

Asked by 3 years ago
Edited 3 years ago

I'm trying to make a reporting system for my game and I got this error

text is not a valid member of player "players.nicemorew"

This is my local script

local player = game.Players.LocalPlayer
local GUI = script.Parent.ReportPlayer
local button = script.Parent.TextButton
local textBox = GUI.TextBox
local submitButton = GUI.TextButton
local event = game.ReplicatedStorage.SendMessages.SendReport

button.MouseButton1Click:Connect(function()
    GUI.Visible = not GUI.Visible
end)

submitButton.MouseButton1Click:Connect(function()
    event:FireServer(player, textBox)
end)

This is my Event script

local httpSevice = game:GetService("HttpService")
local webhook = ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

local function sendReport(Message)
    local data = {
        ["content"] = Message
    }
    wait(1)
    data = httpSevice:JSONEncode(data)
    httpSevice:PostAsync(webhook, data) 
end

game.ReplicatedStorage.SendMessages.OnServerEvent:Connect(function(player, textBox)
    sendReport(player.Name..": "..textBox.Text)
end)

1 answer

Log in to vote
1
Answered by
Neatwyy 123
3 years ago
Edited 3 years ago

When firing a remote event, you don't need to pass in the player on the client. Here's the fixed code! (I also recommend passing the text instead of the textbox itself.)

Local Script:

local player = game.Players.LocalPlayer
local GUI = script.Parent.ReportPlayer
local button = script.Parent.TextButton
local textBox = GUI.TextBox
local submitButton = GUI.TextButton
local event = game.ReplicatedStorage.SendMessages.SendReport

button.MouseButton1Click:Connect(function()
    GUI.Visible = not GUI.Visible
end)

submitButton.MouseButton1Click:Connect(function()
    event:FireServer(textBox.Text) -- Passing the player is not required.
end)

Server Script:

local httpSevice = game:GetService("HttpService")
local webhook = ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

local function sendReport(Message)
    local data = {
        ["content"] = Message
    }
    wait(1)
    data = httpSevice:JSONEncode(data)
    httpSevice:PostAsync(webhook, data) 
end

game.ReplicatedStorage.SendMessages.OnServerEvent:Connect(function(player, textBox)
    sendReport(player.Name..": "..textBox)
end)
Ad

Answer this question