Advertisement
InfinateSpectre

Untitled

Nov 2nd, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer
  2. repeat wait() until game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)
  3.  
  4.  
  5. function getTeammates()
  6. local teammates = {}
  7. for i,v in pairs(game.Players:GetPlayers()) do
  8. if v.Team == plr.Team then
  9. table.insert(teammates,v)
  10. end
  11. end
  12. return teammates
  13. end
  14.  
  15. local target = getTeammates()[math.random(1,#getTeammates())].Name
  16.  
  17. print(target)
  18.  
  19. local function ViewportPointToWorldCoordinates(x, y)
  20.  
  21. local ray = workspace.CurrentCamera:ViewportPointToRay(x, y)
  22. local partHit, endPosition = workspace:FindPartOnRay(Ray.new(ray.Origin, ray.Direction*5000))
  23.  
  24. return endPosition
  25.  
  26. end
  27.  
  28. local function getX()
  29. for i = 1,tonumber(game.workspace.CurrentCamera.ViewportSize.X) do
  30. if ViewportPointToWorldCoordinates(i,1).X == game.workspace[target].HumanoidRootPart.Position.X then
  31. return ViewportPointToWorldCoordinates(i,1).X
  32. end
  33. end
  34. end
  35.  
  36. local function getY()
  37. for i = 1,tonumber(game.workspace.CurrentCamera.ViewportSize.Y) do
  38. if ViewportPointToWorldCoordinates(1,i).Y == game.workspace[target].HumanoidRootPart.Position.Y then
  39. return ViewportPointToWorldCoordinates(i,1).Y
  40. end
  41. end
  42. end
  43.  
  44. local function targetScreenPos()
  45. local x,y = getX(),getY()
  46. return UDim2.new(0,x,0,y)
  47. end
  48.  
  49. local targetScreenPos = targetScreenPos()
  50.  
  51. print(targetScreenPos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement