script to check health of models or name, click on a model
Key RequiredUniversal

script to check health of models or name, click on a model

Universal Scriptsamiencarmonasamiencarmona 3.9K views 18 executesUpdated Jan 5, 2025
Unrated
00
Lua Script•88 lines (2985 chars)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
local hoverLabel = Instance.new("TextLabel", gui)

-- GUI Styling
hoverLabel.Size = UDim2.new(0, 200, 0, 50)
hoverLabel.Position = UDim2.new(0, 10, 0, 10)  -- Starting position
hoverLabel.BackgroundColor3 = Color3.new(0, 0, 0)
hoverLabel.TextColor3 = Color3.new(1, 1, 1)
hoverLabel.TextSize = 16
hoverLabel.Font = Enum.Font.SourceSans
hoverLabel.TextWrapped = true
hoverLabel.Visible = true  -- Always visible

-- Make the label draggable
local dragging = false
local dragInput, dragStart, startPos

hoverLabel.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        dragging = true
        dragStart = input.Position
        startPos = hoverLabel.Position

        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                dragging = false
            end
        end)
    end
end)

hoverLabel.InputChanged:Connect(function(input)
    if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
        local delta = input.Position - dragStart
        hoverLabel.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
    end
end)

-- Function to check if the part belongs to a model, and get the model name and health
local function getModelInfoAndHealth(part)
    if part:IsA("BasePart") then
        local model = part:FindFirstAncestorOfClass("Model")
        if model then
            local humanoid = model:FindFirstChildOfClass("Humanoid")
            if humanoid then
                return model.Name, humanoid.Health
            else
                return model.Name, "No Health (No Humanoid)"
            end
        end
    end
    return nil, nil
end

-- Variable to store the last clicked target
local lastClickedTarget = nil

-- Detect click event to show model name and health
mouse.Button1Down:Connect(function()
    local target = mouse.Target
    if target then
        local modelName, health = getModelInfoAndHealth(target)
        if modelName then
            hoverLabel.Text = "Model: " .. modelName .. "\nHealth: " .. health
            lastClickedTarget = target  -- Store the target for future updates
        else
            hoverLabel.Text = "Clicked part has no model or health"
            lastClickedTarget = nil
        end
    end
end)

-- Always update the health every tick for the last clicked target
while true do
    if lastClickedTarget then
        local modelName, health = getModelInfoAndHealth(lastClickedTarget)
        if modelName then
            hoverLabel.Text = "Model: " .. modelName .. "\nHealth: " .. health
        else
            hoverLabel.Text = "Clicked part has no model or health"
        end
    end
    wait(0.1)  -- Update every 0.1 seconds
end

Features & Information

literally just check the health of any model with no humanoid

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts