HttpService working in studio but not in game client

Hello, developers! For the past hour I’ve been working on a webhook script that sends a message whenever someone joins or leaves the game (including chatlogs). When I run it in studio it seems perfectly normal but when I try to run it ingame (Roblox Game Client) it doesn’t work at all. Does anyone have any idea what could cause this?

Script:

local http = game:GetService('HttpService')
local url = 'WebhookURL'

game.Players.PlayerAdded:Connect(function(plr)

	local data = {

		["content"] = "",
		["embeds"] = {{
			["title"] = "**Game**",
			["description"] = "**"..plr.Name.."** has joined the game!"
		}}
	}

	http:PostAsync(url, http:JSONEncode(data))
	
	plr.Chatted:Connect(function(msg)
		
		data = {
			["content"] = plr.Name.." sent a message: \""..msg.."\""
		}
		
		http:PostAsync(url, http:JSONEncode(data))
		
	end)
	
end)

game.Players.PlayerRemoving:Connect(function(plr)

	local data = {

		["content"] = "",
		["embeds"] = {{
			["title"] = "**Game**",
			["description"] = "**"..plr.Name.."** has left the game!"
		}}
	}

	http:PostAsync(url, http:JSONEncode(data))
end)

Thanks!

If you are sending it to discord then that won’t work anymore. There is a workaround though, here is a video on that: tutorial

2 Likes

If this is discord, it blocks request sent from Roblox unless you use a proxy. The reason it works in studio is cause you are making the get request not the Roblox server.

1 Like

Is there any easier way because I often avoid free models?

You can trust ProxyService it is a very popular module that I personally use and can vouch for

1 Like