I want to acheive this thing in my coding where it would read whenever you type something in ingame chat and it sends it to the discord server through webhook
the Problem is that it doesn’t work trough in-game but it does it in studio
I have Tried Redoing the script over the last 2 days Neither Worked just did it in-Game
local http = game:GetService("HttpService")
local players = game:GetService("Players")
local webhook = "https://discord.com/api/webhooks/911812700806459473/skCSKy2hfzUa8JtKnNDDS02LiorDUkkch0-PBlFzn4o6cuGuPq8ZV_LK-vTvc-Aq0snm"
local function onChatted(plr, msg)
local data = {
content = string.format('`%s:` %s', plr.Name, msg)
}
local jsonData = http:JSONEncode(data)
local response = http:PostAsync(webhook, jsonData)
end
local function onPlayerAdded(plr)
plr.Chatted:Connect(function(msg) onChatted(plr, msg) end)
end
players.PlayerAdded:Connect(onPlayerAdded)
That Webhook is Randomly Generated on a discord webhook that doesn’t exist I did this reply because I know those people who gonna take the ID and do some bad stuff with it
It could be possible that the script is starting after the player is already in the game.
local http = game:GetService("HttpService")
local players = game:GetService("Players")
local webhook = ""
local function onChatted(plr, msg)
local data = {
content = string.format('`%s:` %s', plr.Name, msg)
}
local jsonData = http:JSONEncode(data)
local response = http:PostAsync(webhook, jsonData)
end
local function onPlayerAdded(plr)
plr.Chatted:Connect(function(msg) onChatted(plr, msg) end)
end
for _, plr in ipairs(players:GetPlayers()) do
onPlayerAdded(plr)
end
players.PlayerAdded:Connect(onPlayerAdded)
If that doesn’t work then make sure you have HTTP requests enabled. (Although it might already be if this already works in studio.