Basically, I'm trying to make a webhook that will send all messages being sent in my roblox game to a channel in my discord server
(you may think this would be API abuse but I don't plan to have any more than 10 people in the game at once)
I think the problem could be the variables, but I'm not entirely sure, I'm a bit of a noobie with API.
**The code: **
game.Players:FindFirstChild().Chatted:Connect(function(msg) local text = msg local user = game.Players.LocalPlayer.Name local http = game:GetService("HttpService") local Data = { ["content"] = "`"..text.."`", ["username"] = user, } Data = http:JSONEncode(Data) http:PostAsync("*webhook link redacted.*", Data) end)
There was nothing wrong with any of the http stuff, just a simple mistake with finding the first player, and also no getting a LocalPlayer from a server script:
game.Players.ChildAdded:Wait() local player = game.Players:FindFirstChildOfClass("Player") player.Chatted:Connect(function(msg) local text = msg local user = player.Name local http = game:GetService("HttpService") local Data = { ["content"] = "`"..text.."`", ["username"] = user, } Data = http:JSONEncode(Data) http:PostAsync("", Data) --Put the link you saved between the two quotes. end)