Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

2 comments

0

thx

1 answer

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)

3 comments

0

where is the webhook suppose to be at?

0

HS:PostAsync("webhooklinkhere", payload)

0

Downvoted because you don't explain how it's better

This discussion is preserved as it was. New answers, comments, and votes are closed.