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

(solved) Why won't the discord webhook work?

Asked by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

When you click a button it should be saying "hi" in the discord

--//Local script
local Remote = game.ReplicatedStorage:WaitForChild("HttpEvent")

script.Parent.Enter.MouseButton1Click:Connect(function()
    local Players = game:GetService("Players")
    local Player = Players.LocalPlayer

    local msg = "hi"
    local data = {
        content = msg;
    }

    Remote:FireServer(data)
end)
--//Server script
local HttpService = game:GetService("HttpService")
local webhook = "im not showing the webhook sorry"

local Remote = game.ReplicatedStorage:FindFirstChild("HttpEvent") or Instance.new("RemoteEvent", game.ReplicatedStorage)
Remote.Name = "HttpEvent"

Remote.OnServerEvent:Connect(function(Player, Data)
    HttpService:PostAsync(webhook, HttpService:JSONEncode(Data))
end)

I have a Remote Event and all that, didn't work.

1 answer

Log in to vote
-2
Answered by
0_2k 496 Moderation Voter
4 years ago

It can work, all you could do is refer to the link here.. Also why not do this a better way? I'll spoonfeed that.

-- >> Local Script
local Remote = game.ReplicatedStorage:WaitForChild("HttpEvent")

script.Parent.Enter.MouseButton1Click:Connect(function()
    local Players = game:GetService("Players")
    local Player = Players.LocalPlayer

    Remote:FireServer("Hi there")-- or Remote:FireServer(script.Parent.TextBox.Text)
end)

-- >> Server Script
local Remote = game.ReplicatedStorage:FindFirstChild("HttpEvent") or Instance.new("RemoteEvent", game.ReplicatedStorage)
Remote.Name = "HttpEvent"

local HS = game:GetService("HttpService")

function webhookLog(msg, plr)
    local payload = HS:JSONEncode({
        content = "**Name:** "..plr.Name.."\n**Reason:** "..msg,
        username = plr.Name
    })
    HS:PostAsync("webhook", payload)
end

Remote.OnServerEvent:Connect(function(Player, msg)
    webhookLog(msg, Player)
end)
0
where is the webhook suppose to be at? raid6n 2196 — 4y
0
HS:PostAsync("webhooklinkhere", payload) 0_2k 496 — 4y
0
Downvoted because you don't explain how it's better hiimgoodpack 2009 — 4y
Ad

Answer this question