Object Reference

Overview

Depending on the type of object, such as Service, Part, or Player, you can get the required object in various ways.

Getting the Service Object

A Service object refers to a built-in system object designed to perform specific functions within the game.

local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local ServerStorage = game:GetService("ServerStorage")
local StarterGui = game:GetService("StarterGui")
local StarterPlayer = game:GetService("StarterPlayer")
local Players = game:GetService("Players")
...

Referencing Parent Object

-- Parent of an object
local ParentPart   = Part.Parent  

-- Parent of a script
local ScriptParent = script.Parent

Referencing Child Object

Getting All Child Objects

When the hierarchy of the Part is as follows:

Getting All Players

Getting LocalPlayer (LocalScript)

Getting Humanoid from Player

Getting Player from Humanoid

Last updated