Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr = game.Players.LocalPlayer
- repeat wait() until game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)
- function getTeammates()
- local teammates = {}
- for i,v in pairs(game.Players:GetPlayers()) do
- if v.Team == plr.Team then
- table.insert(teammates,v)
- end
- end
- return teammates
- end
- local target = getTeammates()[math.random(1,#getTeammates())].Name
- print(target)
- local function ViewportPointToWorldCoordinates(x, y)
- local ray = workspace.CurrentCamera:ViewportPointToRay(x, y)
- local partHit, endPosition = workspace:FindPartOnRay(Ray.new(ray.Origin, ray.Direction*5000))
- return endPosition
- end
- local function getX()
- for i = 1,tonumber(game.workspace.CurrentCamera.ViewportSize.X) do
- if ViewportPointToWorldCoordinates(i,1).X == game.workspace[target].HumanoidRootPart.Position.X then
- return ViewportPointToWorldCoordinates(i,1).X
- end
- end
- end
- local function getY()
- for i = 1,tonumber(game.workspace.CurrentCamera.ViewportSize.Y) do
- if ViewportPointToWorldCoordinates(1,i).Y == game.workspace[target].HumanoidRootPart.Position.Y then
- return ViewportPointToWorldCoordinates(i,1).Y
- end
- end
- end
- local function targetScreenPos()
- local x,y = getX(),getY()
- return UDim2.new(0,x,0,y)
- end
- local targetScreenPos = targetScreenPos()
- print(targetScreenPos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement