Hello, so I am making an application center for my friend. I tried to make it so when a player finishes the questions he will press a button that sends a message to a specific discord server.
With that said, I am trying to make it so the script takes the player’s name and inserts it into the discord message.
Here is what I mean: Player Submits > Script gets the player’s name of who submitted > Script sends it over to Discord with a message
Here is my code:
local val1 = game.StarterGui.Application.Main.Questions.Question1.Submit.AnswerVal
local val2 = game.StarterGui.Application.Main.Questions.Question2.Submit.AnswerVal
local val3 = game.StarterGui.Application.Main.Questions.Question3.Submit.AnswerVal
local val4 = game.StarterGui.Application.Main.Questions.Question4.Submit.AnswerVal
local val5 = game.StarterGui.Application.Main.Questions.Question5.Submit.AnswerVal
game.Players.PlayerAdded:Connect(function(player)
script.Parent.MouseButton1Click:Connect(function(click)
local http = game:GetService("HttpService")
local Data = {
["content"] = "**New Submission Request:** \n*Name:*"..player.name.." \n*Age:*"..player.AccountAge.." \n*ID:*"..player.ID.." \n\n**Answer to question 1:**"..val1.Value.." \n**Answer to question 2:**"..val2.Value.." \n**Answer to question 3:**"..val3.Value.." \n**Answer to question 4:**"..val4.Value.." \n**Answer to question 5:**"..val5.Value.."
}
Data = http:JSONEncode(Data)
http:PostAsync("my webhook", Data)
end)
end)
The script works perfectly without the “game.Players.PlayerAdded:Connect(function(player)” part (Without it I can not get the player’s name). But once I added it there it just does not send the message at all.
Also I used both scripts, Local and server.
Sorry if this has already been answered before.
I guess the problem is that server is not that fast, so when you start the server, script might be didn’t loaded yet, so it can’t connect PlayerAdded event before you join.
The thing is that when I do remove the Player Added event and add a LocalPlayer. The script just gives me an error and does not send anything to the server.
It is currently on a server script.
Even when I switched to a Local script, and replaced player.name with a LocalPlayer, the script did not send anything to the discord server.
this will fire the webhook’s call for every player when the button is pressed.
just stop using server scripts for client UI input and instead use a local script and use a remote event with the webhook’s code listening for when the button is pressed…