Trying to get LocalPlayer within a Script

-- HttpSender (Script)
hs = game:GetService("HttpService")
url = "My Discord WebHook Here"

local event1 = game.ReplicatedStorage.AntiExploit
event1.OnServerEvent:connect(function(player)
local date = os.date("!*t")
local Data = {
	["Player Name"] = player.Name,
	["Player ID"] = player.userId,
	["Date"] = date.month..date.day..date.year
}
Data = hs:JSONEncode(Data)
hs:PostAsync(url, Data)
end)

-- Handler (LocalScript)
local humanoid = script.Parent:WaitForChild("Humanoid")

humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()

if humanoid.WalkSpeed ~= 16 then

game.ReplicatedStorage.AntiExploit:FireServer()

end

end)

Hopefully you can help me!

Could you describe your problem in greater detail?

So, every time I try to fire the remote it returns back an HTTP 400 Error.

Are HTTP requests on? If you don’t know where it is in, then it’s in the Game Settings.

1 Like

Are HTTP requests on? If so, are you using the discord proxy for your webhook by any chance?

Found here: Roblox Discord Webhook Proxy Server

Discord blocked webhook requests from Roblox so a proxy is needed.

1 Like

Yes, they are enabled I made sure before posting a thread and I tried much more.

Your message to the Discord API is probably malformed somehow. 400 means bad request.

1 Like

I tried using another script where I connected the webhook to a GUI and it fired correctly. With the webhook saying “Functioning!”

Are you also changing the Webhook link to the roblox server which is https://discord.osyr.is/api/webhooks/?

I tried that, it doesn’t seem to work.

It’s definitely the proxy thing as mentioned by @8w_a, I’m pretty sure that the http request from a local script would be sent via the player’s IP and therefore not blocked.

It still doesn’t work, is it possible I can set up my own proxy?

Yes, with much effort. You could try to use a nodejs server if you’re familiar with JavaScript, which is similar enough to Lua.

Thanks, I will try that out. If not then I will ask some people at my school.

I would first ensure that your request to Discord is written correctly because that’d be the simplest fix, writing & hosting your own proxy server is pretty much a project in its own right.

Albeit off-topic, I’d just like to stick it in here that Discord isn’t necessarily meant to be a logging service and it could potentially result in your webhook being deleted, or further disciplinary action. You should also really not log exploiter usernames - this is a part of manual moderation, which isn’t scalable in a production environment. Handle counterexploitation without a third party.

This remote also has no security, so it can be fired off at a constant rate. Even if the proxy respects rate limits, you’re still capable of overloading the proxy server and having your webhook blacklisted by the proxy’s owner.

And, at the end of it all, this client-side check can be easily circumvented. You shouldn’t really waste your time on things that don’t matter. The most you’ll stop is an exploiter who isn’t dedicated enough to bypass the check.

1 Like

That’s not a thing, people would just make http requests to IP logging sites on everyone’s client if that worked.

1 Like

I’m pretty sure you can’t post http requests from clients on Roblox.

https://developer.roblox.com/api-reference/function/HttpService/GetAsync

1 Like

Good point, @posatta mentioned something similar . OP seemed to imply that it worked in a LocalScript earlier so I just assumed that the difference would be a blocked IP or an unblocked IP.