I’ve recently added a report feature to my game, and for some reason the script only works in studio and comes up with an error when in a real server.
Here’s some info below:
Error Message:
Server-Side Script:
local function filter(text,player)
local msg = chat:FilterStringAsync(text, player, player)
return msg;
end
Events.Report.OnServerEvent:Connect(function(player,reason,user)
local formatted = httpsService:JSONEncode({
content = "Reporting: "..filter(user, player).."\nReason: "..filter(reason, player);
username = player.Name..":"..player.UserId;
avatar_url = ('https://www.roblox.com/headshot-thumbnail/image?userId=' .. player.UserId .. '&width=420&height=420&format=png')
})
httpsService:PostAsync(webook, formatted)
end)
Client-Side Script:
Report.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
if Reason.Text ~= "" then
Events.Report:FireServer(Reason.Text, Username.Text)
end
Reason.Text = "Your have successfully reported "..Username.Text.."!"
wait(1)
Reason.Text = "Enter your reasoning here..."
Username.Text = "Username"
debounce = false
end
end)
Not sure why it only works in studio, so if you know, please do help me out! Thanks!
May not have anything to do with it, but you misspelt webhook (its a variable name, so if you did it wrong twice, then it shouldn’t matter)
Also, what is the URL/Value of webook
The variables are the same name, so it shouldn’t create any errors. The value of “webook” is just a discord webhook so it shouldn’t be posting any errors, I left that part out of the script for safety reasons.
Full script: (Stared the last parts of the URL)
local webook = "https://discord.com/api/webhooks/926186406802501685/yeZojuEo9A9br4dS7Wy-1or4N9mqdhF5jXpFLut5xJ**********************************"
local httpsService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local chat = game:GetService("Chat")
local Events = ReplicatedStorage:WaitForChild("Events")
local function filter(text,player)
local msg = chat:FilterStringAsync(text, player, player)
return msg;
end
Events.Report.OnServerEvent:Connect(function(player,reason,user)
local formatted = httpsService:JSONEncode({
content = "Reporting: "..filter(user, player).."\nReason: "..filter(reason, player);
username = player.Name..":"..player.UserId;
avatar_url = ('https://www.roblox.com/headshot-thumbnail/image?userId=' .. player.UserId .. '&width=420&height=420&format=png')
})
httpsService:PostAsync(webook, formatted)
end)