Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local camera = workspace.CurrentCamera
- local model = workspace.Model
- local cameraPosition = camera.CFrame.p
- local modelPosition = model.PrimaryPart.Position
- local head = model.Head
- local distance = (cameraPosition - head.Position).Magnitude
- RunService.RenderStepped:Connect(function()
- print(distance)
- end)
- local textLabel = Instance.new("TextLabel")
- textLabel.Parent = head
- textLabel.Size = UDim2.new(0, 100, 0, 50)
- textLabel.BackgroundTransparency = 1
- textLabel.TextColor3 = Color3.new(1, 1, 1)
- textLabel.TextStrokeTransparency = 0
- textLabel.Font = Enum.Font.SourceSansBold
- textLabel.TextScaled = true
- local hasSteelHelmet = model:FindFirstChild("SteelHelmet") ~= nil
- RunService.RenderStepped:Connect(function()
- local screenPosition, onScreen = camera:WorldToScreenPoint(head.Position)
- if onScreen then
- textLabel.Visible = true
- textLabel.Position = Vector2.new(screenPosition.X, screenPosition.Y)
- textLabel.Color = hasSteelHelmet and Color3.new(1, 0, 0) or Color3.new(1, 1, 1)
- else
- textLabel.Visible = false
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement