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 3 years ago
Edited 3 years ago
local url = "" --webhook link--
local http = game:GetService("HttpService")
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(player)
local data = {
    ['embeds'] = {{
        ['title'] = "Button clicked",
        ['description'] = player.Name .. " has clicked the button",
        ['url'] = "https://www.roblox.com/users/".. player.UserId .. "/profile"

    }}
}

local finaldata = http:JSONEncode(data)
http:PostAsync(url, finaldata)

end)

Edit: My Error

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 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