LocalScript

LocalScript : BaseScript

Overview

A LocalScript is an instance used to run client-side code.

When the Enabled property is set to true and the client-side script is placed in StarterPlayerScripts, StarterCharacterScripts, or StarterGui, it will run in a new thread.

A running script continues to run unless it is explicitly stopped or encounters a critical error. Errors that occur inside functions connected to events do not stop the script from running.

If the script itself or any of its ancestor Objects is fully removed using Destroy(), the script stops running. However, if the script's Parent is set to nil but the Object remains in memory, the script will continue to run.

Since this script runs on each player's device (local environment), it's used to control client-only features like the Camera, UserInputService, or PlayerGui, as well as to manage UI interactions.

You can also access the player Object running the client directly using the game.Players.LocalPlayer property. This allows you to create behaviors based on the player's screen state or input.

Properties

Methods

Events

Last updated