Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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