So, I was wondering if it is possible to get the playername from a simple onClicked function such as:
function onClicked()
end
script.Parent.MouseButton1Down:connect(onClicked)
Any help would be appreciated.
So, I was wondering if it is possible to get the playername from a simple onClicked function such as:
function onClicked()
end
script.Parent.MouseButton1Down:connect(onClicked)
Any help would be appreciated.
The MouseButton1Click event does not return the player that clicked. If you want to get the player then index LocalPlayer in game.Players.
--Define the player
local plr = game.Players.LocalPlayer
function onClicked()
print(plr.Name)
end
script.Parent.MouseButton1Down:connect(onClicked)
NOTE: This will only work in a localscript.
This discussion is preserved as it was. New answers, comments, and votes are closed.