Advertisement
HowToRoblox

RadarHandler

Sep 3rd, 2020 (edited)
3,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local radarBG = script.Parent:WaitForChild("Background")
  2.  
  3. local playerDotTemplate = game.ReplicatedStorage:WaitForChild("PlayerDot")
  4.  
  5.  
  6. local plr = game.Players.LocalPlayer
  7.  
  8. local char = plr.Character or plr.CharacterAdded:Wait()
  9.  
  10.  
  11. game:GetService("RunService").RenderStepped:Connect(function()
  12.    
  13.     radarBG:ClearAllChildren()
  14.    
  15.     local uiAspectRatioConstraint = Instance.new("UIAspectRatioConstraint", radarBG)
  16.    
  17.    
  18.     for i, otherPlayer in pairs(game.Players:GetPlayers()) do
  19.        
  20.         local otherChar = otherPlayer.Character
  21.        
  22.         if otherPlayer ~= plr then
  23.             if otherChar and otherChar:FindFirstChild("HumanoidRootPart") and char:FindFirstChild("HumanoidRootPart") then
  24.                
  25.                 local playerDot = playerDotTemplate:Clone()
  26.                
  27.                
  28.                 local offset = otherChar.HumanoidRootPart.Position - char.HumanoidRootPart.Position
  29.                
  30.                 local distance = 1/200
  31.                 offset = offset * distance
  32.                 playerDot.Position = UDim2.new(offset.X + 0.5, 0, offset.Z + 0.5, 0)
  33.                
  34.                
  35.                 playerDot.Parent = radarBG
  36.             end
  37.         else
  38.            
  39.             local playerDot = playerDotTemplate:Clone()
  40.            
  41.             playerDot.Position = UDim2.new(0.5, 0, 0.5, 0)
  42.             playerDot.Parent = radarBG
  43.         end
  44.     end
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement