Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local Camera = workspace.CurrentCamera
- local DrawingAPI = {}
- local function CreateTextLabel(Model)
- DrawingAPI[Model] = Drawing.new("Text")
- DrawingAPI[Model].Visible = false
- DrawingAPI[Model].Size = 20
- DrawingAPI[Model].Color = Color3.new(1, 1, 1)
- DrawingAPI[Model].Center = true
- DrawingAPI[Model].Outline = true
- end
- local Heads = {}
- local function UpdateHeads()
- for _, Model in pairs(workspace:GetChildren()) do
- if Model:IsA("Model") and Model.Name == "Model" then
- local Head = Model:FindFirstChild("Head")
- if Head then
- Heads[Model] = Head
- CreateTextLabel(Model)
- end
- end
- end
- end
- UpdateHeads()
- workspace.ChildAdded:Connect(function(Model)
- if Model:IsA("Model") and Model.Name == "Model" then
- local Head = Model:FindFirstChild("Head")
- if Head then
- Heads[Model] = Head
- CreateTextLabel(Model)
- end
- end
- end)
- workspace.ChildRemoved:Connect(function(Model)
- if Heads[Model] then
- Heads[Model] = nil
- DrawingAPI[Model]:Destroy()
- DrawingAPI[Model] = nil
- end
- end)
- local function CheckSteelHelmet(Model)
- local Armor = Model:FindFirstChild("Armor")
- local HasSteelHelmet = false
- if Armor then
- local SteelHelmet = Armor:FindFirstChild("SteelHelmet")
- if SteelHelmet then
- HasSteelHelmet = true
- end
- end
- return HasSteelHelmet
- end
- RunService.RenderStepped:Connect(function()
- for Model, Head in pairs(Heads) do
- local ScreenPosition, OnScreen = Camera:WorldToScreenPoint(Head.Position)
- if OnScreen then
- DrawingAPI[Model].Visible = true
- DrawingAPI[Model].Position = Vector2.new(ScreenPosition.X, ScreenPosition.Y)
- DrawingAPI[Model].Text = " (" .. math.floor((Head.Position - Camera.CFrame.p).Magnitude) .. ")"
- DrawingAPI[Model].Color = CheckSteelHelmet(Model) and Color3.new(1, 0, 0) or Color3.new(1, 1, 1)
- else
- DrawingAPI[Model].Visible = false
- end
- end
- end)
- local modelTable = {}
- local models = workspace:GetChildren()
- for i, model in ipairs(models) do
- if model:FindFirstChild("Head") and model:FindFirstChild("Humanoid") then
- local textLabel = Instance.new("TextLabel")
- textLabel.Parent = model.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
- modelTable[model] = {textLabel = textLabel, hasSteelHelmet = hasSteelHelmet}
- end
- end
- workspace.ChildAdded:Connect(function(child)
- if child:FindFirstChild("Head") and child:FindFirstChild("Humanoid") then
- local textLabel = Instance.new("TextLabel")
- textLabel.Parent = child.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 = child:FindFirstChild("SteelHelmet") ~= nil
- modelTable[child] = {textLabel = textLabel, hasSteelHelmet = hasSteelHelmet}
- end
- end)
- workspace.ChildRemoved:Connect(function(child)
- if modelTable[child] then
- modelTable[child] = nil
- end
- end)
- local camera = workspace.CurrentCamera
- game:GetService("RunService").RenderStepped:Connect(function()
- for model, data in pairs(modelTable) do
- local distance = (camera.CFrame.p - model.Head.Position).Magnitude
- if distance < 20 then
- data.textLabel.Text = "Hello"
- data.textLabel.Visible = true
- if data.hasSteelHelmet then
- data.textLabel.TextColor3 = Color3.new(0, 1, 0)
- else
- data.textLabel.TextColor3 = Color3.new(1, 0, 0)
- end
- else
- data.textLabel.Visible = false
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement