Advertisement
ColdSpecs

Untitled

Sep 16th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. local Camera = workspace.CurrentCamera
  2. local DrawingAPI = {}
  3. local function GetHead(Model)
  4. return Model:FindFirstChild("Head")
  5. end
  6. local function CheckSteelHelmet(Model)
  7. local Armor = Model:FindFirstChild("Armor")
  8. return Armor and Armor:FindFirstChild("SteelHelmet")
  9. end
  10. for _, Model in pairs(workspace:GetChildren()) do
  11. if Model:IsA("Model") and Model ~= game.Players.LocalPlayer.Character then
  12. local Head = GetHead(Model)
  13. if Head then
  14. DrawingAPI[Model] = Drawing.new("Text")
  15. DrawingAPI[Model].Visible = false
  16. DrawingAPI[Model].Size = 20
  17. DrawingAPI[Model].Center = true
  18. DrawingAPI[Model].Outline = true
  19. end
  20. end
  21. end
  22. workspace.ChildAdded:Connect(function(Model)
  23. if Model:IsA("Model") and Model ~= game.Players.LocalPlayer.Character then
  24. local Head = GetHead(Model)
  25. if Head then
  26. DrawingAPI[Model] = Drawing.new("Text")
  27. DrawingAPI[Model].Visible = false
  28. DrawingAPI[Model].Size = 20
  29. DrawingAPI[Model].Center = true
  30. DrawingAPI[Model].Outline = true
  31. end
  32. end
  33. end)
  34. workspace.ChildRemoved:Connect(function(Model)
  35. if DrawingAPI[Model] then
  36. DrawingAPI[Model]:Remove()
  37. DrawingAPI[Model] = nil
  38. end
  39. end)
  40. game:GetService("RunService").RenderStepped:Connect(function()
  41. for Model, Text in pairs(DrawingAPI) do
  42. local Head = GetHead(Model)
  43. if Head then
  44. local ScreenPosition, OnScreen = Camera:WorldToScreenPoint(Head.Position)
  45. if OnScreen then
  46. Text.Visible = true
  47. Text.Position = Vector2.new(ScreenPosition.X, ScreenPosition.Y)
  48. Text.Text = " (" .. math.floor((Head.Position - Camera.CFrame.p).Magnitude) .. ")"
  49. Text.Color = CheckSteelHelmet(Model) and Color3.new(1, 0, 0) or Color3.new(1, 1, 1)
  50. else
  51. Text.Visible = false
  52. end
  53. end
  54. end
  55. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement