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
01 | local player = game.Players.LocalPlayer |
02 | local GUI = script.Parent.ReportPlayer |
03 | local button = script.Parent.TextButton |
04 | local textBox = GUI.TextBox |
05 | local submitButton = GUI.TextButton |
06 | local event = game.ReplicatedStorage.SendMessages.SendReport |
07 |
08 | button.MouseButton 1 Click:Connect( function () |
09 | GUI.Visible = not GUI.Visible |
10 | end ) |
11 |
12 | submitButton.MouseButton 1 Click:Connect( function () |
13 | event:FireServer(player, textBox) |
14 | end ) |
This is my Event script
01 | local httpSevice = game:GetService( "HttpService" ) |
02 | local webhook = ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? |
03 |
04 | local function sendReport(Message) |
05 | local data = { |
06 | [ "content" ] = Message |
07 | } |
08 | wait( 1 ) |
09 | data = httpSevice:JSONEncode(data) |
10 | httpSevice:PostAsync(webhook, data) |
11 | end |
12 |
13 | game.ReplicatedStorage.SendMessages.OnServerEvent:Connect( function (player, textBox) |
14 | sendReport(player.Name.. ": " ..textBox.Text) |
15 | end ) |
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:
01 | local player = game.Players.LocalPlayer |
02 | local GUI = script.Parent.ReportPlayer |
03 | local button = script.Parent.TextButton |
04 | local textBox = GUI.TextBox |
05 | local submitButton = GUI.TextButton |
06 | local event = game.ReplicatedStorage.SendMessages.SendReport |
07 |
08 | button.MouseButton 1 Click:Connect( function () |
09 | GUI.Visible = not GUI.Visible |
10 | end ) |
11 |
12 | submitButton.MouseButton 1 Click:Connect( function () |
13 | event:FireServer(textBox.Text) -- Passing the player is not required. |
14 | end ) |
Server Script:
01 | local httpSevice = game:GetService( "HttpService" ) |
02 | local webhook = ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? |
03 |
04 | local function sendReport(Message) |
05 | local data = { |
06 | [ "content" ] = Message |
07 | } |
08 | wait( 1 ) |
09 | data = httpSevice:JSONEncode(data) |
10 | httpSevice:PostAsync(webhook, data) |
11 | end |
12 |
13 | game.ReplicatedStorage.SendMessages.OnServerEvent:Connect( function (player, textBox) |
14 | sendReport(player.Name.. ": " ..textBox) |
15 | end ) |