I am trying to make a weebhook based off of this turorial
and the thing is, it works, just one problem, I want to make the weebhook send what the user sends, but when I set it to the player input as seen below it gives me this error:
HTTP 400(Bad Request).
If I set it to a pre-set string, it works. Any idea how to solve this.
Code:
local http = game:GetService("HttpService")
local PlayerInput = game.StarterGui.PokeMessagingSystem.Frame.TextBox.Text
game.ReplicatedStorage["Discord webhook"].OnServerEvent:Connect(function(player, msg, rec, send)
local Data = {
["content"] = PlayerInput
}
Data = http:JSONEncode(Data)
http:PostAsync("I HAVE DELETED THE WEBHOOK SO YOU CAN STOP SPAMMING @EVERYONE GEEZ", Data)
print("Sent!")
end)
He is trying to get the text of a TextBox in StarterGui which is an empty string because when players input their own text, it changes the TextBox in their PlayerGui, not StarterGui.
This would require the use of a RemoteEvent to send data between the client and server. And for reference StarterGui is only a placeholder for a game’s GUIs. During run time the GUIs players see are stored in their Player instance.
Local Script
game.Players.LocalPlayer.PlayerGui.PokeMessagingSystem.Frame.TextBox.FocusLost:Connect(function(enterPressed)
if enterPressed then
game.ReplicatedStorage.RemoteEvent:FireServer(game.Players.LocalPlayer.PlayerGui.PokeMessagingSystem.Frame.TextBox.Text)
end
end)
Server Script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,text)
local Data = {
["content"] = text
}
Data = http:JSONEncode(Data)
http:PostAsync("STOP SPAMMING @EVERYONE WITH THIS GEEZ", Data)
print("Sent!")
end)
Well your method of gathering the text is invaild since you are using StarterGui. You can’t do this 100% on the server and you will need a mix of server and local scripts.