Instances

Helpers for instance references: cloning, comparing, firing interaction events, and the hidden UI and reference cache.

Overview

Helpers for the instance tree: references a game can't trace back to you, comparing them, firing interaction events a player would normally trigger, and getting the hidden UI container.

cloneref is the one to remember. It gives you a reference to the same instance that isn't equal to the original, so a game doing == checks or using instances as table keys won't recognise it.

cloneref and gethui
local Players = game:GetService("Players")

-- A reference the game's own bookkeeping will not match.
local me = cloneref(Players.LocalPlayer)
print(me == Players.LocalPlayer)              --> false
print(compareinstances(me, Players.LocalPlayer)) --> true

-- Somewhere to put UI the game cannot find by walking PlayerGui.
local gui = Instance.new("ScreenGui")
gui.Parent = gethui()

Reference handling

Firing events

These fire the events a player interaction would, without actually doing the interaction. Range and line of sight checks the game does in Luau still apply. This skips the input, not the game's logic.

Callbacks & connections