Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why does does this script work in Roblox Studio, but not in the actual game itself?

Asked by 4 years ago

I am making a Discord Webhook for the chat in Roblox. So, whenever somebody talks in the game, it announces it in this separate channel on Discord. I've tested it out several times in Roblox Studio and it said in the Discord chat what I said in Roblox Studio, which is amazing! I then save the game and go to the actual game and test it out, but whenever I say something in the game, it doesn't appear in the Discord channel. I thought it didn't save, so I went back to Roblox Studio and it did save. I then added a model to make sure, left then rejoined and the model was there. I've tried several different ways. The script is below. Please help!

local url = WEBHOOK URL (not saying the actual webhook url here)
local https = game:GetService("HttpService")

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        local data = {
            ["embeds"] = {{
                color = 000000,
                title = "Training Chat Bot",
                fields = {
                    {
                        name = player.Name,
                        value = msg
                    }
                    }
                }}
        }
        local newdata = https:JSONEncode(data)
        https:PostAsync(url,newdata)
    end)
end)

1 answer

Log in to vote
0
Answered by 4 years ago

I've had a look and it, and it surprisingly works for me now. I've removed you an extra line of code and crammed it into the https:PostAsync() section.

local url = "url"
local https = game:GetService("HttpService")

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        local data = {
            ["embeds"] = {{
                color = 000000,
                title = "Training Chat Bot",
                fields = {
                    {
                        name = player.Name,
                        value = msg
                    }
                    }
                }}
        }
        https:PostAsync(url,https:JSONEncode(data))
    end)
end)

Please accept this answer if you felt it helped.

0
Note; You must have HttpsRequests turned on in studio. jensar141215 157 — 4y
0
It didn't work, but I still accepted it! Goldenkings11 -11 — 4y
0
Cheers, can you elaborate? Are you sure you have HttpsRequests on in the studio and are you putting the URL in the right place? jensar141215 157 — 4y
Ad

Answer this question