Head Dot using Game API

It's not necessary to use the Game API to achieve this, but for proper demonstration purposes of this portion of the API it was done this way.

local cached_heads = {};

local function on_update()
    cached_heads = {};
    local workspace = game.get_workspace()
    for _, child in pairs(workspace:get_children()) do
        if (child:is_a("Model")) then
            local head_part = child:find_first_child("Head");
            if (head_part) then
                cached_heads[#cached_heads + 1] = vector(head_part:get_position());
            end
        end
    end
end

local function on_paint()
    for _, head_position in pairs(cached_heads) do
        local x, y = utility.world_to_screen(head_position:unpack());
        render.circle(x, y, 2, 0, 255, 127, 255, 4)
    end
end

cheat.set_callback("update", on_update)
cheat.set_callback("paint", on_paint)

Last updated