No it still doesn’t work for some reason, still no error.
Listening to a MouseButton1Click from StarterGui will never work, you need to listen to it from the player’s PlayerGui.
This needs to be in a server script, to my knowledge you can’t use any aspect of HTTPService from the client, even if you can it is not recommended (your discord webhook link will be leaked)
Why listen for a remote event if you are just going to distinguish via a MouseButton1Click anyway?
To summarize:
Listen to the MouseButton1Click through a LocalScript inside of the text button and fire a remote event using a script like:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(--[[Parameters]])
end)
Then use a serverscript to detect that and fire the webhook:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,--[[parameters]])
-- send webhook
end)
Hopefully this is able to squash your bugs.
What do I put in
game.ReplicatedStorage.RemoteEvent:FireServer(--[[Parameters]])
What do I put in the --[[Parameters]]) part?
The information you are trying to send through the webhook, which I assume is the “question1a, question2a” etc.
I highly recommend AGAINST running an (apparent) application system through Discord though, seeing-as Discord has a 2,000 character limit which you can’t exceed. Big vouch for a Trello application system in the long run.
I had made a discord tutorial on Webhooks a while ago, it might be helpful in this case.
Also ensure that your Http Services are turned on in the game settings
This is what I used for my Feedback UI
Client side
local db = false
feedbackMain.SendButton.MouseButton1Click:Connect(function()
if not db and maxCharacters - #feedbackMain.InputBox.Input.Text >= 0 then
db = true
local msg = feedbackMain.InputBox.Input.Text
feedbackMain.InputBox.Input.Text = "Sending Message..."
local response = game.ReplicatedStorage.FilteringFunction:InvokeServer(msg)
feedbackMain.InputBox.Input.Text = response
wait(5)
if feedbackMain.InputBox.Input.Text == response then
feedbackMain.InputBox.Input.Text = "Type feedback/bug report here"
end
db = false
end
end)
The above code basically will first check if the Characters are not more than max characters and then Invoke the Filtering function in Replicated Storage, btw i didnt show you the variable above I assume you know how to do it.
local webhookURL = "https://discordapp.com/api/webhooks/xxxx/xxxxxxx"
local filteringFunction = game.ReplicatedStorage.FilteringFunction
local ChatService = game:GetService("Chat")
local HTTP = game:GetService("HttpService")
function filteringFunction.OnServerInvoke(player, msg)
local FilteredMessage = ChatService:FilterStringForBroadcast(msg, player)
--Filter the message, before sending it to the webhook.
local payload = HTTP:JSONEncode({
content = FilteredMessage,
username = "Submitted By "..player.Name
})
HTTP:PostAsync(webhook, payload)
return "Feedback recieved!"
end
That code should be in Server Side, so most likely in the ServerScriptService. The above code takes the argument that was passed on to the function and then stores the filtered message in payload and then posts a Http Request to the webhook with the Payload we have in JSON format.
Okay thank you, cya later have a nice day, Bye, cya!
You need to filter the text you’re receiving from the user, or your game could be taken down.
Yes, Sir. Thank you, alright have a nice day!
So I followed your tutorial, but some part of it had an error, and that was the content part!
local HS = game:GetService("HttpService")
local WebhookURL = "https://discordapp.com/api/redatced
local SubmitButton = script.Parent.SubmitButton
--Replace your link with the link in the Quotes.
SubmitButton.MouseButton1Click:Connect(function(Player,Question1A,Question2A,Question3A,Question4A,Question5A,Question6A)
local Player = game.Players.LocalPlayer
local Question1A = script.Parent.Question1
local Question2A = script.Parent.Question2
local Question3A = script.Parent.Question3
local Question4A = script.Parent.Question4
local Question5A = script.Parent.Question5
local Question6A = script.Parent.Question6
local MessageData = {
["content"] = Player.."Has applied for, "..Question1A..", "..Question2A..", "..Question3A..", "..Question4A..", "..Question5A..", "..Question6A.."."
}
MessageData = HS:JSONEncode(MessageData)
--We used JSONEncode to convert the Lua Table into a Json String
HS:PostAsync(WebhookURL,MessageData)
end)
Wait the script doesn’t look at the right place, what i meant to say is fire a remote function from the client side and handle the HttpRequest in server side script
Oh crap, someone just took my API and spammed “KFX then the N word with a nude picture” I am so god dang mad right now, I’m so stupid, he’s going to get me banned. And also, where do I put the script?
But he wasn’t successful because it was only me in the discord
Oof, be sure to hide your link. This is what you probably want to do
In starter gui, localscript
local plr = game.Players.LocalPlayer
plr.PlayerGui.ApplicationGui.ApplicationMainFrame.SubmitButton.MouseButton1Click:Connect(function()
local question1a = game.StarterGui.ApplicationGui.ApplicationMainFrame.Question1.Text
local question2a = game.StarterGui.ApplicationGui.ApplicationMainFrame.Question2.Text
local question3a = game.StarterGui.ApplicationGui.ApplicationMainFrame.Question3.Text
local question4a = game.StarterGui.ApplicationGui.ApplicationMainFrame.Question4.Text
local question5a = game.StarterGui.ApplicationGui.ApplicationMainFrame.Question5.Text
local question6a = game.StarterGui.ApplicationGui.ApplicationMainFrame.Question6.Text
local Function = game:GetService("ReplicatedStorage").SendFunction
Function.InvokeServer(plr, question1a, question2a, question3a, question4a, question5a, question6a)
end)
Make another script in ServerScripts which contains the following
local webhookURL = "https://discordapp.com/api/webhooks/xxxx/xxxxxxx"
local filteringFunction = game.ReplicatedStorage.FilteringFunction
local ChatService = game:GetService("Chat")
local HTTP = game:GetService("HttpService")
function filteringFunction.OnServerInvoke(player, question1a, question2a, question3a, question4a, question5a, question6a)
local msg = plr.Name.." Has applied for, "..Question1A..", "..Question2A..", "..Question3A..", "..Question4A..", "..Question5A..", "..Question6A.."."
local FilteredMessage = ChatService:FilterStringForBroadcast(msg, player)
--Filter the message, before sending it to the webhook.
local payload = HTTP:JSONEncode({
content = FilteredMessage,
username = "Submitted By "..plr.Name
})
HTTP:PostAsync(webhook, payload)
return "Application Received"
end
Also havent tested the code as i am on mobile, there might be some errors.
Ah, Okay error is SendFunction is not there nor is Invoke server, what do I do with those?
I didnt quite understand what you said
What is send function and invoke server.
local Function = game:GetService("ReplicatedStorage").SendFunction
Function.InvokeServer(plr, question1a, question2a, question3a, question4a, question5a, question6a)
end)
it won’t work because nothig named that is in there.
Why would he need to filter it? If the player is typing in an application, and the only other place said text is going to is discord, there’s no apparent need to filter it as other clients will not ever see it at that point. Discord is a 13 years+ service and doesn’t have restrictions to what you can say either.
So have a fix to what i said, sendfunction and invoke server?
Nice question, but Roblox has a statement which states that any client input should be filtered before sending to external servers, so ideally you should filter any content sent to external servers or might result in getting your account banned.