We use cookies on this site to enhance your user experience
Collapse Sidebar


The games uses this function is to create the Players/LocalPlayer. Since this item is protected, attempting to use it in a Script or LocalScript will cause an error.

Although you cannot create the LocalPlayer, you can reference the LocalPlayer created by a game using the following code in a LocalScript:

	local player = game.Players.LocalPlayer


Return Type Summary

A Player instance for the created local player

Code Samples

Creating a LocalPlayer

This example demonstrates that the Players/CreateLocalPlayer function executes without error if using the Command Bar or a Plugin and errors if executed in a LocalScript.

-- Command bar
local player = game.Players:CreateLocalPlayer() -- Returns a `Player` instance for the created local player

-- LocalScript
local player = game.Players:CreateLocalPlayer() -- Errors