Hi i need help I need do If player click on button then I need something check BUT Click event work only on Script So I don’t know how to detect player who clicked
script.Parent.MouseButton1Click:Connect(function()
local HttpService = game:GetService("HttpService")
local s = "Censored WebHook"
print("ok3")
if game.Players.LocalPlayer:GetRankInGroup(5174745) >= 203 then
print("ok")
local Name = game.Players.LocalPlayer.Name
local Data = {
["username"] = "Training Information Bot",
["content"] = "Training at 9:00AM has beed booked by"..Name
}
local DataDone = HttpService:JSONEncode(Data)
script.Parent.Publish:InvokeServer(DataDone,s)
end
end)
So the problem doesn’t seem to be in your LocalScript, rather the server-side script that listens when the Publish RemoteFunction gets invoked.
There’s another issue with your code currently though, which is the fact that if an exploiter in your game figures out the webhook since it’s exposed to the client, they could spam it very easily.
The script is pretty insecure,
so I’d suggest you to rewrite it to only fire to the server when the button gets clicked and then you do the rest on the server.
What I would do is (and what is likely conventional):
Move the ScreenGui into the PlayerGui
Set the ‘Adornee’ of the ScreenGui to ‘Part’
This will show a unique GUI for each player/client where you are able to reference LocalPlayer. This will work in a LocalScript. This will mean that the Script will no longer work and you’d have to move the Publish event somewhere else, but it will be much neater.
The url is probably invalid, assuming you’re using discord webhooks, here’s a guide to creating a webhook. Then you should copy the URL and paste it in where ever you are storing the webhook link.