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

Why won't Http execute? I've tried a few timing messing with the code. No luck.

Let me explain what's its suppose to do,

When someone clicks the button, it will tell the system to send a message in a channel. The bot or webhook will say "(game player) is noob) I've tried messing with it, no luck.

Output: 6:18:37.951 - Http requests can only be executed by game server

script.Parent.Body1.Search.MouseButton1Click:Connect(function()
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local HttpService = game:GetService("HttpService")
local webhook = "webhook"
local msg = Player.Name.."is noob"
		local data = {
			content = msg;
		}
		HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
		end)

1 answer

✓ Accepted answer

All you have to do is set up a RemoteEvent and pass in the msg data. Then inside of the server you can handle the HttpService stuff.

You have to do it like this because "Http requests can only be executed by game server".

Try this

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

script.Parent.Body1.Search.MouseButton1Click:Connect(function()
	local Players = game:GetService("Players")
	local Player = Players.LocalPlayer
	
	local msg = Player.Name.."is noob"
    local data = {
        content = msg;
    }

	Remote:FireServer(data)
end)
--//Server script
local HttpService = game:GetService("HttpService")
local webhook = "webhook"

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)

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