local Discord = require(11780461670)
local button = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.ImageButton
local textBox = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextBox
Discord.SetWebhook("https://discord.com/api/webhooks/1259110789449650226/C7IYPeH1vnOSZUTPizKk7aGiWbOyjq32CqlcZyhaWmQJtsK9HCKrAXPUTRFu_0JHCWHW")
button.MouseButton1Down:Connect(function()
print("does it work? yes it does!")
local input = textBox.Text
print(input)
textBox.Text = ""
Discord.Embed("", input, "A new submission has been made.", "0xF57D34")
end)
This might take a remote event which is fairly easy to code if you want this to interact with the server.
If the script is located in ServerScriptService it might cause a bit of trouble, we can use a remote event to send the infornmation.
Local script
-- VARIABLES
local RemoteEvent = -- Place of remote event
local Discord = require(11780461670)
local button = script.Parent
local textBox = script.Parent:WaitForChild('textBox')
Discord.SetWebhook("https://discord.com/api/webhooks/1259110789449650226/C7IYPeH1vnOSZUTPizKk7aGiWbOyjq32CqlcZyhaWmQJtsK9HCKrAXPUTRFu_0JHCWHW")
-- FUNCTIONS
button.MouseButton1Down:Connect(function()
local input = textBox.Text
RemoteEvent:FireServer(Input)
end)
Server Script
local RemoteEvent = -- Place of remote event
RemoteEvent.OnServerEvent:Connect(Function(Player, Input)
print("does it work? yes it does!")
print(input)
textBox.Text = ""
Discord.Embed("", input, "A new submission has been made.", "0xF57D34")
end)
Idk if this will work, I usually code with a auto correct feature and I don’t have a full scope of what this is supposed to do.
You could also put the server script into the player gui if you don’t want to separate them into two different scripts.
Sorry I should’ve read your code more clearly the first time. Let me give you some code you can take:
Create a remote function in replicated storage simply using the + icon like you did before when adding scripts.
-- Do this in a local script
local RF = game.ReplicatedStorage.RemoteFunction
local Discord = RF:InvokeServer()
local button = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")Frame.ImageButton
local textBox = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.TextBox
Discord.SetWebhook("https://discord.com/api/webhooks/1259110789449650226/C7IYPeH1vnOSZUTPizKk7aGiWbOyjq32CqlcZyhaWmQJtsK9HCKrAXPUTRFu_0JHCWHW")
button.MouseButton1Down:Connect(function()
print("does it work? yes it does!")
local input = textBox.Text
print(input)
textBox.Text = ""
Discord.Embed("", input, "A new submission has been made.", "0xF57D34")
end)
-- Do this in the script in serverscriptservice
local RF = game.ReplicatedStorage.RemoteFunction
RF.OnServerInvoke = function(plr)
local Discord = require(11780461670)
return Discord
end
Hopefully this works but I may be wrong. Test it out.
By the way I changed it a bit sorry, so copy and paste it again.
Does the local script stay under the ImageButton? I’m getting an error thrown regarding line 13 and I believe it’s because I’m placing the local script wrong.
Okay I made a mistake again, this time it should work.
Add a remote event into replicatedstorage instead of a remote function and use this new code.
-- Paste this in the local script
local RE = game.ReplicatedStorage.RemoteEvent
local button = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.ImageButton
local textBox = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.TextBox
button.MouseButton1Down:Connect(function()
RE:FireServer(textbox)
end)
-- Paste this in the script in serverscriptservice
local Discord = require(11780461670)
local RE = game.ReplicatedStorage.RemoteEvent
Discord.SetWebhook("https://discord.com/api/webhooks/1259110789449650226/C7IYPeH1vnOSZUTPizKk7aGiWbOyjq32CqlcZyhaWmQJtsK9HCKrAXPUTRFu_0JHCWHW")
RE.OnServerEvent:Connect(function(plr, textbox)
textBox.Text = ""
Discord.Embed("", input, "A new submission has been made.", "0xF57D34")
end)
Thank you so much! After a bit of trial and error with HTTP requests, I managed to get the script working:
-- local script
local RE = game.ReplicatedStorage.RemoteEvent
local button = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.ImageButton
local textBox = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Frame.TextBox
button.MouseButton1Down:Connect(function()
RE:FireServer(textBox)
end)
-- serverscriptservice script
local RE = game.ReplicatedStorage.RemoteEvent
local url = "https://discord.com/api/webhooks/1259110789449650226/C7IYPeH1vnOSZUTPizKk7aGiWbOyjq32CqlcZyhaWmQJtsK9HCKrAXPUTRFu_0JHCWHW"
local http = game:GetService("HttpService")
RE.OnServerEvent:Connect(function(plr, textBox)
local textInput = textBox.Text
local data = {
['embeds'] = {{
['title'] = textInput,
['description'] = "A new submission has been made: **"..textInput.."**",
['color'] = tonumber(0xF57D34)
}
}
}
local finalData = http:JSONEncode(data)
http:PostAsync(url, finalData)
textBox.Text = ""
end)
Side question, do you have any idea why the script can’t grab the player’s textbox input? If you help me solve this too, I’ll be super thankful.
hey this is off topic but … from my knowledge, discord ban roblox from using their api unless you are in studio. This is because people made games allowing users under 13 to use discord without a discord acc through a game on roblox
To be honest i’m not an expert at using httpservice lol, all I knew was that you have to require from the server instead of the client. So I’m not sure.