Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

(I need help)When button clicked it finds player username then posts on discord webhook?

Asked by 4 years ago
Edited 4 years ago
01local url = "" --webhook link--
02local http = game:GetService("HttpService")
03local player = game.Players.LocalPlayer
04script.Parent.MouseButton1Click:Connect(function(player)
05local data = {
06    ['embeds'] = {{
07        ['title'] = "Button clicked",
08        ['description'] = player.Name .. " has clicked the button",
09        ['url'] = "https://www.roblox.com/users/".. player.UserId .. "/profile"
10 
11    }}
12}
13 
14local finaldata = http:JSONEncode(data)
15http:PostAsync(url, finaldata)
16 
17end)

Edit: My Error

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

MouseButton1Click cannot get the player as far as I know. Try using a LocalScript, Script, and RemoteEvent, because RemoteEvents automatically pass the player object as the first parameter.

Edit: Because it's in the gui, you could script.Parent.Parent, etc. to get the player's name.

Ad

Answer this question