Skip to content

tw.camera.free

Side: Client | Aliases: tw.cam, tw.freecam

Interactive freecam system for cinematic camera control. tw.camera.free is callable directly as a shorthand for tw.camera.free.start.

Functions

tw.camera.free.start(options?)

Starts the freecam. This function is blocking — it yields the current thread until the freecam is stopped.

ParameterTypeDefaultDescription
options.interpolateinteger?Interpolation duration in ms for smooth camera transition
options.show_promptsboolean?trueShow control prompts on screen
options.rangenumber?10000Maximum distance the camera can travel from start point
lua
tw.camera.free.start({
    interpolate = 500,
    show_prompts = true,
    range = 5000,
})
-- code here runs after freecam is stopped

tw.camera.free.stop()

Stops the freecam and restores the previous camera state.

lua
tw.camera.free.stop()

tw.camera.free.isActive() -> boolean

Returns whether the freecam is currently active.

Returns: boolean

lua
if tw.camera.free.isActive() then
    print("Freecam is running")
end

tw.camera.free.getCam() -> integer

Returns the camera handle used by the freecam, or -1 if inactive.

Returns: integer — Camera handle or -1

lua
local cam = tw.camera.free.getCam()
if cam ~= -1 then
    local pos = GetCamCoord(cam)
end

tw.camera.free.lockRotate()

Locks camera rotation. The camera can still move but cannot rotate.

lua
tw.camera.free.lockRotate()

tw.camera.free.unlockRotate()

Unlocks camera rotation, restoring full control.

lua
tw.camera.free.unlockRotate()

tw.camera.free.isLocked() -> boolean

Returns whether camera rotation is currently locked.

Returns: boolean

lua
if tw.camera.free.isLocked() then
    print("Rotation is locked")
end

tw.camera.free.getPromptGroup() -> string

Returns the prompt group identifier used by the freecam controls.

Returns: string

ConVars

Speed, rotation sensitivity, and key bindings can be adjusted via ConVars:

ConVarDescription
SpeedCamera movement speed
RotationMouse rotation sensitivity
KeysKey bindings for movement and controls

Examples

Basic freecam with smooth transition

lua
tw.camera.free.start({
    interpolate = 1000,
    range = 500,
})
-- player regains control here after stopping

Callable shorthand

lua
-- tw.camera.free() is equivalent to tw.camera.free.start()
tw.camera.free({
    show_prompts = false,
})

Lock rotation for a placement system

lua
tw.camera.free.start({ show_prompts = true })

-- In another thread:
tw.camera.free.lockRotate()
-- Player can only move, not rotate
tw.camera.free.unlockRotate()

Notes

  • tw.camera.free.start() is blocking. Code after the call only executes once the freecam is stopped.
  • tw.camera.free() can be called directly as a function and behaves identically to tw.camera.free.start().
  • The player ped is frozen and invisible while the freecam is active. Previous state is restored on stop.
  • The range option limits how far the camera can travel from the starting point.

Premium RedM Scripts — Multi-Framework