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

How do you send a variable to a server for a Discord Webhook to print?

I am creating a Feedback GUI in my game that allows users to report bug, exploiters and general feedback. I want it so when you type in your feedback, a event is fired that the server picks up and sends a HTTP request to my Discord webhook. I don't know why but when the variable ' bug ' is sent over, it prints as my username.

Client side -

local url = "My url"

local http = game:GetService("HttpService")

local feedbackGUI = script.Parent.Parent.Parent.Feedback

local submitButton = feedbackGUI.submit.TextButton

local textBox = feedbackGUI.wrtitingBox

local optionsGUI = script.Parent.Parent

local webhook = game.ReplicatedStorage.Feedback

--Buttons

local bugButton = script.Parent.Bug
local feedbackButton = script.Parent.Feedback
local hackerButton = script.Parent.Hacker


bugButton.MouseButton1Click:Connect(function()
	
	optionsGUI:TweenPosition(UDim2.new(20, 0,6.64, 0), Enum.EasingDirection.In,Enum.EasingStyle.Bounce,1.5,true)
	wait(1)
	feedbackGUI.hotbar.TextLabel.Text = "Zoo Tycoon : Bug"
	feedbackGUI.wrtitingBox.PlaceholderText = "Type your bug here!"
	feedbackGUI:TweenPosition(UDim2.new(1.119, 0,6.626, 0), Enum.EasingDirection.Out,Enum.EasingStyle.Bounce,1.5,true)
	
	submitButton.MouseButton1Click:Connect(function()
		
		local bug = textBox.Text
		feedbackGUI:TweenPosition(UDim2.new(20, 0,6.64, 0), Enum.EasingDirection.In,Enum.EasingStyle.Bounce,1.5,true)
		
		webhook:FireServer(bug)
	
	end)
end)

Server Side

local url = "My url"

local http = game:GetService("HttpService")


game.ReplicatedStorage.Feedback.OnServerEvent:Connect(function(theBug)
	
	print(theBug)
	
	local HookData = {
	
	['username'] = "feedback", 
	
	['content'] = theBug
	}
	
		
	HookData = http:JSONEncode(HookData)
	http:PostAsync(url, HookData) 

end)

1 comment

0

Firstly remove ur webhook's link, don't leak it!

2 answers

Hello the problem is in your SERVER SIDED script it's because your script is :

local url = "https://discordapp.com/api/webhooks/702093286642417734/OBOtYs53NzT13o1nTQpfP1Az8fU59xihM8aOcdZVKd25JIyT-0uGfcxX8iSGVvlzCf3O"

local http = game:GetService("HttpService")


game.ReplicatedStorage.Feedback.OnServerEvent:Connect(function(theBug)

    print(theBug)

    local HookData = {

    ['username'] = "feedback", 

    ['content'] = theBug
    }


    HookData = http:JSONEncode(HookData)
    http:PostAsync(url, HookData) 

end)

The problem game.ReplicatedStorage.Feedback.OnServerEvent:Connect(function(theBug) it prints your players name cause in a RemoteEvent or RemoteFunction the first variable of a listener is the player then the variables you want to set example remote.OnServerEvent:Connet(function(player,thebug)

The fix:

local url = "https://discordapp.com/api/webhooks/702093286642417734/OBOtYs53NzT13o1nTQpfP1Az8fU59xihM8aOcdZVKd25JIyT-0uGfcxX8iSGVvlzCf3O"

local http = game:GetService("HttpService")


game.ReplicatedStorage.Feedback.OnServerEvent:Connect(function(player,theBug)

    print(theBug)

    local HookData = {

    ['username'] = "feedback", 

    ['content'] = theBug
    }


    HookData = http:JSONEncode(HookData)
    http:PostAsync(url, HookData) 

end)

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