Advertisement
RobloxScripterExp

Mouse Target Player's Name Script

Oct 31st, 2021
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. --- With this you can get player's name, but with click - Player:GetMouse() ---
  2.  
  3. --- With setclipboard (auto-copy player name by clicking) ---
  4.  
  5. local mouse = game.Players.LocalPlayer:GetMouse()
  6.  
  7. mouse.Button1Down:Connect(function()
  8. if mouse.Target then
  9. local model = mouse.Target:FindFirstAncestorOfClass("Model")
  10.  
  11. if model then
  12. local player = game.Players:FindFirstChild(model.Name)
  13. if player then
  14. setclipboard(player.Name)
  15. end
  16. end
  17. end
  18. end)
  19.  
  20.  
  21. --- With print (prints player name by clicking) ---
  22.  
  23. local mouse = game.Players.LocalPlayer:GetMouse()
  24.  
  25. mouse.Button1Down:Connect(function()
  26. if mouse.Target then
  27. local model = mouse.Target:FindFirstAncestorOfClass("Model")
  28.  
  29. if model then
  30. local player = game.Players:FindFirstChild(model.Name)
  31. if player then
  32. print(player) --- if not work, then change to print(player.Name)
  33. end
  34. end
  35. end
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement