Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.