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)
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)