Skip to content
Untitled Sandbox - Developer Documentation
docs/types/Player

Player

A player who is connected to the server, which your scripts get from events like players.joined.

Fields

idnumber
user_idnumber
namestring
positionvector
aliveboolean
healthnumber
max_healthnumber
walk_speednumber
jump_heightnumber
climbingboolean
climb_speednumber
teamTeam?
velocityvector

Events

health_changedEvent<(Player, number, number)>

You listen to these with :connect, which the Event page covers.

Player:kill

method

Sets the player's health to 0, which kills them straight away.

Player:kill() -> ()
example
player:kill()

Use it forkill bricks, falling off the map, or losing a round.

Player:damage

method

Takes health away from the player, and can say which player caused it.

Player:damage(amount: number, by: Player?) -> ()
example
player:damage(25)

Use it forlava, traps and weapons, or anything else that should hurt players.

amountHealth to take away.
byoptionalThe player who did it. Damage by a teammate does nothing while friendly fire is off.

Player:heal

method

Gives the player health back, but never more than their max health.

Player:heal(amount: number) -> ()
example
player:heal(10)

Use it forhealth packs, healing zones, or potions that players drink.

amountHealth to give, up to max_health.

Player:respawn

method

Brings the player back at a spawn point right away.

Player:respawn() -> ()
example
player:respawn()

Use it forrestart buttons, or sending everyone back home after a round.

Player:teleport

method

Moves the player straight to a position, or onto an instance.

Player:teleport(target: vector | Instance) -> ()
example
player:teleport(math3d.vector3.new(0, 10, 0))

Use it forportals, obby checkpoints, or moving players into the arena.

targetA position within 100000 studs of the origin, or an instance to go to.

Player:sit

method

Seats the player on a seat, and says whether it worked.

Player:sit(seat: Instance) -> boolean
example
local seated = player:sit(part)

Use it forputting players in a car, a ride or a chair from a script.

seatAn instance that is a seat.

Player:stand

method

Gets the player up from the seat they are sitting in.

Player:stand() -> ()
example
player:stand()

Use it forkicking players out of a vehicle when the ride is over.

Player:spawn

method

Brings the player back at a spawn point, a team's spawn, or a position you choose.

Player:spawn(at: (Instance | vector | Team | string)?) -> ()
example
player:spawn("Red")

Use it forsending players to their team's base when a match starts.

atoptionalA spawn point, a position, a team or a team name. Nil picks a spawn point as usual.

Player:exists

method

Says whether the player is still in the server or has left.

Player:exists() -> boolean
example
if player:exists() then player:heal(10) end

Use it forchecking the player did not leave while your script was waiting.

Player:apply_impulse

method

Pushes the player as if an explosion hit them.

Player:apply_impulse(impulse: vector) -> ()
example
player:apply_impulse(math3d.vector3.new(0, 300, 0))

Use it forjump pads, explosions, or knockback when a player gets hit.

impulseThe push. A player's mass is 20.

Player:kick

method

Disconnects the player from the server, and shows them the reason.

Player:kick(reason: string?) -> ()
example
player:kick("See you soon!")

Use it forremoving players who break the rules, or closing the server down.

reasonoptionalWhat the player sees, cut to 200 characters.
↑ ↓ moveEnter openEsc close