Syntax
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")Examples
Create a server-only template
Script in ServerScriptService. The unparented part is configured, then stored outside the visible world. It does not appear in the scene until cloned into Workspace.
local ServerStorage = game:GetService("ServerStorage")
local template = Instance.new("Part")
template.Name = "LessonPlatform"
template.Anchored = true
template.Size = Vector3.new(8, 1, 8)
template.Parent = ServerStorage
local platform = template:Clone()
platform.Position = Vector3.new(0, 4, 0)
platform.Parent = workspaceCheck a required object without waiting forever
A separate Script in ServerScriptService. Create an anchored Part named SpawnMarker in Workspace first. FindFirstChild returns immediately; a failed lookup can produce a useful setup message.
local marker = workspace:FindFirstChild("SpawnMarker")
if not marker or not marker:IsA("BasePart") then
warn("Create a BasePart named SpawnMarker in Workspace")
return
end
print(marker.Position)Best practices
- Use GetService for services rather than relying on an Explorer display name.
- Use WaitForChild when an object is expected to arrive later, and handle timeouts when its presence is uncertain.
- Do not poll the whole Workspace each frame to locate an object you can retain or track with events.
Runtime & versions
Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Luau documentation