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

01local player = game.Players.LocalPlayer
02local GUI = script.Parent.ReportPlayer
03local button = script.Parent.TextButton
04local textBox = GUI.TextBox
05local submitButton = GUI.TextButton
06local event = game.ReplicatedStorage.SendMessages.SendReport
07 
08button.MouseButton1Click:Connect(function()
09    GUI.Visible = not GUI.Visible
10end)
11 
12submitButton.MouseButton1Click:Connect(function()
13    event:FireServer(player, textBox)
14end)

This is my Event script

01local httpSevice = game:GetService("HttpService")
02local webhook = ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
03 
04local function sendReport(Message)
05    local data = {
06        ["content"] = Message
07    }
08    wait(1)
09    data = httpSevice:JSONEncode(data)
10    httpSevice:PostAsync(webhook, data)
11end
12 
13game.ReplicatedStorage.SendMessages.OnServerEvent:Connect(function(player, textBox)
14    sendReport(player.Name..": "..textBox.Text)
15end)

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:

01local player = game.Players.LocalPlayer
02local GUI = script.Parent.ReportPlayer
03local button = script.Parent.TextButton
04local textBox = GUI.TextBox
05local submitButton = GUI.TextButton
06local event = game.ReplicatedStorage.SendMessages.SendReport
07 
08button.MouseButton1Click:Connect(function()
09    GUI.Visible = not GUI.Visible
10end)
11 
12submitButton.MouseButton1Click:Connect(function()
13    event:FireServer(textBox.Text) -- Passing the player is not required.
14end)

Server Script:

01local httpSevice = game:GetService("HttpService")
02local webhook = ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
03 
04local function sendReport(Message)
05    local data = {
06        ["content"] = Message
07    }
08    wait(1)
09    data = httpSevice:JSONEncode(data)
10    httpSevice:PostAsync(webhook, data)
11end
12 
13game.ReplicatedStorage.SendMessages.OnServerEvent:Connect(function(player, textBox)
14    sendReport(player.Name..": "..textBox)
15end)
Ad

Answer this question