Advertisement
ColdSpecs

totum

Sep 6th, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. local DrawingAPI = {}
  2.  
  3. local reallyRed = Color3.fromRGB (255, 0, 0)
  4.  
  5. local limeGreen = Color3.fromRGB (9, 194, 0)
  6.  
  7. local function GetState (model)
  8. for _, part in pairs (model:GetChildren ()) do
  9. if part.Name == "State" then
  10. return part
  11. end
  12. end
  13. end
  14.  
  15. local function CreateTextLabel (model)
  16.  
  17. DrawingAPI [model] = Drawing.new ("Text")
  18. DrawingAPI [model].Visible = false
  19. DrawingAPI [model].Size = 20
  20. DrawingAPI [model].Color = Color3.new (1, 1, 1)
  21. DrawingAPI [model].Center = true
  22. DrawingAPI [model].Outline = true
  23. end
  24.  
  25. local function CreateCircleLogo (model)
  26.  
  27. DrawingAPI [model] = Drawing.new ("Circle")
  28. DrawingAPI [model].Visible = false
  29. DrawingAPI [model].Radius = 10
  30. DrawingAPI [model].Color = Color3.new (0, 0, 1)
  31. DrawingAPI [model].Filled = true
  32. end
  33.  
  34. local function UpdateDrawingObjects ()
  35.  
  36. for _, model in pairs (workspace:GetChildren ()) do
  37.  
  38. if model:IsA ("Model") and model ~= game.Players.LocalPlayer.Character then
  39.  
  40. local state = GetState (model)
  41.  
  42. if state and (state.Color == reallyRed or state.Color == limeGreen) then
  43.  
  44. if not DrawingAPI [model] then
  45.  
  46. if state.Color == reallyRed then
  47. CreateTextLabel (model)
  48. elseif state.Color == limeGreen then
  49. CreateCircleLogo (model)
  50. end
  51. end
  52. else
  53. if DrawingAPI [model] then
  54. DrawingAPI [model]:Remove ()
  55. DrawingAPI [model] = nil
  56. end
  57. end
  58. end
  59. end
  60. end
  61.  
  62. local function DrawDrawingObjects ()
  63.  
  64. local camera = workspace.CurrentCamera
  65. local cameraPos = camera.CFrame.p
  66.  
  67. for model, drawingObject in pairs (DrawingAPI) do
  68.  
  69. local screenPos, onScreen = camera:WorldToScreenPoint (model.PrimaryPart.Position)
  70.  
  71. if onScreen then
  72.  
  73. drawingObject.Visible = true
  74. drawingObject.Position = Vector2.new (screenPos.X, screenPos.Y)
  75.  
  76. if drawingObject.ClassName == "Text" then
  77. drawingObject.Text = "Decaying"
  78. end
  79. else
  80. drawingObject.Visible = false
  81. end
  82. end
  83. end
  84.  
  85. game:GetService ("RunService").RenderStepped:Connect (function ()
  86. UpdateDrawingObjects ()
  87. DrawDrawingObjects ()
  88. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement