Advertisement
Guest User

HALP

a guest
Jun 30th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. -- Configurable Constants
  2. local RANGE = 128
  3. local RADAR_DIM = 20
  4.  
  5. -- Services
  6. local RS = game:GetService("RunService")
  7.  
  8. -- Player Objects
  9. local plr = game.Players.LocalPlayer
  10.  
  11. repeat wait() until plr.Character
  12. local char = plr.Character
  13.  
  14. local torso = char:WaitForChild("Torso")
  15. local hum = char:WaitForChild("Humanoid")
  16.  
  17. local cam = workspace.CurrentCamera
  18.  
  19. -- UI Objects
  20. local radarGui = script.Parent
  21. local radarFrame = radarGui.Radar
  22.  
  23. -- Shoots a ray from a position
  24. local function shootRay(pos)
  25.         local ray = Ray.new(pos, Vector3.new(0, -1024, 0))
  26.         local hit, pos, normal, material = workspace:FindPartOnRay(ray, char)
  27.         return (hit ~= nil) and hit.BrickColor.Color or false
  28. end
  29.  
  30. local steps = 0
  31.  
  32. -- Bind to RenderStep
  33. RS:BindToRenderStep("UpdateRadar", Enum.RenderPriority.Last.Value, function()
  34.         steps = steps + 1
  35.         if steps % 10 ~= 0 then return end
  36.         local radarChildren = radarFrame:GetChildren()
  37.         for i = 1, #radarChildren do
  38.                 radarChildren[i]:Destroy()
  39.         end
  40.         if torso.Parent then -- If the torso still exists
  41.                 local torsoPos = torso.Position + Vector3.new(0, 64, 0)
  42.                 local cam2DLookVector = Vector3.new(
  43.                         cam.CoordinateFrame.lookVector.X, 0, cam.CoordinateFrame.lookVector.Z
  44.                 ).unit
  45.                 local torsoPointCF = CFrame.new(torsoPos, torsoPos + cam2DLookVector)
  46.                 local inc = RANGE / RADAR_DIM
  47.                 for x = -RANGE/2 + inc/2, RANGE/2 - inc/2, inc do
  48.                         for y = -RANGE/2 + inc/2, RANGE/2 - inc/2, inc do
  49.                                 local pos = (torsoPointCF * CFrame.new(x, 0, y)).p
  50.                                 local color = shootRay(pos)
  51.                                 if color then
  52.                                         local ui_x = (x + RANGE/2 - inc/2) / inc
  53.                                         local ui_y = (y + RANGE/2 - inc/2) / inc
  54.                                         local pixel = Instance.new("Frame", radarFrame) do
  55.                                                 pixel.Size = UDim2.new(1/RADAR_DIM, 0, 1/RADAR_DIM, 0)
  56.                                                 pixel.Position = UDim2.new(ui_x/RADAR_DIM, 0, ui_y/RADAR_DIM, 0)
  57.                                                 pixel.BackgroundColor3 = color
  58.                                                 pixel.BorderSizePixel = 0
  59.                                         end
  60.                                 end
  61.                         end
  62.                 end
  63.         end
  64. end)
  65.  
  66. hum.Died:connect(function()
  67.         RS:UnbindFromRenderStep("UpdateRadar")
  68. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement