Advertisement
ColdSpecs

**Needs to be implemented**

Aug 31st, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2. local camera = workspace.CurrentCamera
  3. local model = workspace.Model
  4.  
  5. local cameraPosition = camera.CFrame.p
  6. local modelPosition = model.PrimaryPart.Position
  7.  
  8. local head = model.Head
  9.  
  10. local distance = (cameraPosition - head.Position).Magnitude
  11.  
  12. RunService.RenderStepped:Connect(function()
  13. print(distance)
  14. end)
  15.  
  16. local textLabel = Instance.new("TextLabel")
  17. textLabel.Parent = head
  18. textLabel.Size = UDim2.new(0, 100, 0, 50)
  19. textLabel.BackgroundTransparency = 1
  20. textLabel.TextColor3 = Color3.new(1, 1, 1)
  21. textLabel.TextStrokeTransparency = 0
  22. textLabel.Font = Enum.Font.SourceSansBold
  23. textLabel.TextScaled = true
  24.  
  25. local hasSteelHelmet = model:FindFirstChild("SteelHelmet") ~= nil
  26.  
  27. RunService.RenderStepped:Connect(function()
  28.  
  29. local screenPosition, onScreen = camera:WorldToScreenPoint(head.Position)
  30. if onScreen then
  31.  
  32. textLabel.Visible = true
  33. textLabel.Position = Vector2.new(screenPosition.X, screenPosition.Y)
  34. textLabel.Color = hasSteelHelmet and Color3.new(1, 0, 0) or Color3.new(1, 1, 1)
  35. else
  36.  
  37. textLabel.Visible = false
  38. end
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement