Lesson 10 of 12
Physics: constraints, assemblies, network ownership
Learn Roblox physics from Beacon Yard's exhibit. A hinged sign, a roped crate and welded meshes teach constraints, assemblies and network ownership, and why the drone stays anchored.
By the end you can
- Join parts with HingeConstraint, RopeConstraint and WeldConstraint and predict how each moves
- Explain what an assembly is and why anchoring one part changes the whole assembly
- Decide which machine should simulate a part, and when to keep it on the server
- Filter collisions with collision groups, and let players drag a part with a DragDetector the server checks
Before this: The drone: movement, targeting, damage, NPCs and pathfinding: the scrap crawler
Step 1 of 11
Push the sign
In the south-west corner of the yard there is a small exhibit: a wooden sign on a post, a crate tied to a metal hitch, and a lamp. Walk into the sign and it swings away from you, then settles. Shove the crate and it slides until the rope goes tight. No script moves either of them after Play starts.
The sign swings on a hinge with no motor; the crate stops when its 8-stud rope is tight.
Transcript
- 0:04 The sign swings on SignHinge. Nothing motors it back.
- 0:09 The limits are minus 55 and plus 55 degrees.
- 0:12 The rope stops the crate at 8 studs.
The physics engine moved them. ExhibitService arrives at m06-drone-wrench (the milestone this lesson's BuildAlong moves you to from m05-the-round) and only builds the parts and the joints once at boot. This lesson is about those joints, called ConstraintConstraintA physics joint between two attachments, such as a hinge, rope, weld or spring.Think of it as a hinge, a rope or glue between two parts.s, and about who runs the physics.
After Play starts, what moves the sign when you walk into it?
Press 1 to 4 to choose, Enter to check.
Step 2 of 11
A hinge: rotation around one axis
A HingeConstraint joins two attachments so the parts can only rotate around one shared axis: Attachment0's X axis1. The post is anchored; the sign is not, so the sign is the part that turns.
local hinge = Instance.new("HingeConstraint")
hinge.Name = "SignHinge"
hinge.Attachment0 = hingeAttachment(post, "HingePost", hingeOnPost)
hinge.Attachment1 = hingeAttachment(sign, "HingeSign", signAttach)
hinge.ActuatorType = Enum.ActuatorType.None
hinge.LimitsEnabled = true
hinge.LowerAngle = -55
hinge.UpperAngle = 55
hinge.Restitution = 0.15
hinge.Parent = post
ActuatorType decides whether the hinge drives itself. Motor spins at an angular velocity, Servo turns to a target angle, and None, used here, does nothing on its own. Limits keep the swing between -55° and 55°, and Restitution 0.15 makes the sign bounce only a little off those stops.
LowerAngle is -55 and UpperAngle is 55. Through how many degrees can the sign swing from one stop to the other?
Step 3 of 11
A rope: a maximum, not a rod
A RopeConstraint keeps two attachments from getting farther apart than its Length. They may come closer; then the rope is slack2. CrateRope ties the top of the hitch to the top of the crate with a length of 8.
local rope = Instance.new("RopeConstraint")
rope.Name = "CrateRope"
rope.Attachment0 = pointAttachment(hitch, "RopeHitch", Vector3.new(0, hitch.Size.Y / 2, 0))
rope.Attachment1 = pointAttachment(crate, "RopeCrate", Vector3.new(0, CRATE_SIZE.Y / 2, 0))
rope.Length = ROPE_LENGTH
rope.Visible = true
rope.Thickness = 0.12
rope.Color = BrickColor.new("Cocoa")
rope.Parent = hitch
Someone sets crate.Anchored = true in ExhibitService. What happens when you shove the crate?
local crate = part(exhibit, "Crate", CRATE_SIZE, position, color, Enum.Material.WoodPlanks, true)
Press 1 to 4 to choose, Enter to check.
Step 4 of 11
Welds and assemblies
A WeldConstraint holds two parts in the same position relative to each other, touching or not3. Parts joined by welds move as one rigid body, an assembly. Movable joints such as hinges join assemblies into a bigger mechanism4.
Beacon Yard uses welds to hang uploaded meshes on gameplay parts. The coin, the drone and the beacon each clone their mesh, switch off its collision, touch and query, make it Massless, and weld it to the invisible part the game actually uses. The drone's root is anchored and its mesh copies Anchored from it, so that weld joins two anchored parts and is inactive. The mesh follows because PivotTo moves the whole model. A weld does its real work on unanchored parts, such as a crate.
descendant.Anchored = parent.Anchored
descendant.CanCollide = false
descendant.CanTouch = false
descendant.CanQuery = false
descendant.Massless = true
local weld = Instance.new("WeldConstraint")
weld.Part0 = parent
weld.Part1 = descendant
weld.Parent = descendant
Massless matters: a heavy mesh welded to a light part would change how the assembly moves. Switching off CanQuery and CanTouch keeps the costume out of raycasts and touch events, so the art can change without changing the game.
An unanchored crate has a large, decorative metal mesh welded to it, with Massless off. What changes?
Press 1 to 4 to choose, Enter to check.
Step 5 of 11
Who runs the physics
Physics in Roblox is shared out. The server always owns anchored parts. For unanchored parts, the engine gives the simulation to a nearby player's device, so pushing the crate feels instant for the player doing it5. That machine is the part's network owner.
Both sidesRemember: Network ownership is whoever holds the ball.
Through m06-drone-wrench, Beacon Yard never calls SetNetworkOwner (the scrap crawler at m08-crawler is the first to). The sign and the crate follow the default rule, and that is fine for loose props. The drone is the opposite case. Its root is anchored, so the server always owns it, and no client can ever move the part the wrench raycast is aimed at.

Select a numbered pin, or a row below, to read what it marks.
The exhibit at rest. Select a pin to see which constraint holds each part.
A player stands right next to the crate and nobody has called SetNetworkOwner. Which machine most likely simulates the crate?
Press 1 to 4 to choose, Enter to check.
Step 6 of 11
Where the ball picture breaks
Holding a ball means you control it, and that is the problem. Answer first, then open the breakdown.
Where does it break?“Whoever holds the ball” is a good picture of network ownership. Where does it stop being true?
It breaks here. The server can take the ball back at any time and always keeps anchored parts, and the holder is trusted with positions it reports, so a cheating holder can move the ball anywhere.
The true model. Each unanchored assembly is simulated by one machine. Clients near it usually own it for responsiveness; their simulated positions replicate to the server. Anything gameplay-critical is anchored or kept server-owned, and the server validates results instead of trusting the owner.
Match each object to the ownership it should have.
Step 7 of 11
Build it: the exhibit
Other ways pros do this
| Option | What it is | When pros pick it | Trade-offs |
|---|---|---|---|
| Constraints | Hinge, rope, spring, prismatic and mover constraints solved by the physics engine. | Doors, signs, ropes, vehicles: anything that should react to collisions. What the exhibit uses. | Behaviour depends on mass and ownership, and is harder to make exactly repeatable. |
| Tweens on anchored parts | TweenService moves an anchored part along a fixed curve. | Gates, lifts and anything that must end in an exact place, like Beacon Yard's gates. | No physical reaction; a player standing in the way is pushed or clipped. |
| Scripted CFrame each frame | The server sets a CFrame on Heartbeat, as the drone does. | Enemies and hitboxes that must be server-authoritative. | You write the motion, and moving a part this way never fires Touched. |
Build along
src/server/ExhibitService.luausrc/server/init.server.luau
In the game repo, run
git diff m05-the-round m06-drone-wrench -- src/server/init.server.luauand opensrc/server/ExhibitService.luauatm06-drone-wrench.You should see ExhibitService.luau is new, and init.server.luau calls ExhibitService.start(map.yard) right after RoundService.start.
Run
rojo serve, connect Studio, press Play and expand the exhibit in Explorer.You should see Workspace.Yard.PhysicsExhibit holds SignPost, Sign, Hitch, Crate, LampPost and Lamp, with SignHinge under the post and CrateRope under the hitch.
Switch to the Server view, select
SignHinge, then switch back and walk into the sign.You should see Pushing the sign makes it swing and settle; CurrentAngle on SignHinge changes in the Properties window and stays between -55 and 55.
Push the crate away from the hitch.
You should see The crate stops moving away once the rope is drawn as a straight line between the hitch and the crate.
Step 8 of 11
Who blocks whom: collision groups
At m14-ship the yard has a drone and a scrap crawler. Before you change anything, predict what happens when they meet.
The drone flies straight through the spot where the crawler is walking. What happens?
root.Anchored = true
root.CanCollide = false -- the drone's root, in DroneService
Press 1 to 4 to choose, Enter to check.
The crawler is solid, and so are players. Two problems follow. Players crowd the coin pads and block each other, and a few players standing in a gap between scrap stacks can wall the crawler in. A collision group fixes both. Every part has a CollisionGroup name, "Default" unless you change it, and a table of rules says which groups collide. Register groups and set rules with workspace:RegisterCollisionGroup and workspace:CollisionGroupSetCollidable; the old PhysicsService versions are deprecated. Do it from one script, because script order is not guaranteed. Studio shows the table in Window ⟩ 3D ⟩ Collision Groups6.
-- src/server/CollisionRules.luau, started first in init.server.luau
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local CollisionRules = {}
local function put(part: Instance, group: string)
if part:IsA("BasePart") then
part.CollisionGroup = group
end
end
function CollisionRules.start()
workspace:RegisterCollisionGroup("Players")
workspace:RegisterCollisionGroup("Crawler")
workspace:CollisionGroupSetCollidable("Players", "Players", false)
workspace:CollisionGroupSetCollidable("Players", "Crawler", false)
local function onCharacter(character: Model)
for _, part in character:GetDescendants() do
put(part, "Players")
end
character.DescendantAdded:Connect(function(part)
put(part, "Players")
end)
end
local function onPlayer(player: Player)
player.CharacterAdded:Connect(onCharacter)
if player.Character then
onCharacter(player.Character)
end
end
Players.PlayerAdded:Connect(onPlayer)
for _, player in Players:GetPlayers() do
onPlayer(player)
end
CollectionService:GetInstanceAddedSignal("Crawler"):Connect(function(root)
put(root, "Crawler")
end)
end
return CollisionRules
Both groups still collide with Default, so walls, scrap and the crate stop players and the crawler as before. The crawler can still bite you: its attack is a distance check, not a bump.
Build along
src/server/CollisionRules.luausrc/server/init.server.luau
Add
CollisionRules.luau, require it ininit.server.luau, and callCollisionRules.start()beforeCrawlerServicestarts so the first crawler's root is caught by the tag signal.You should see Window ⟩ 3D ⟩ Collision Groups during Play lists Default, Players and Crawler, with Players against Players and Players against Crawler unticked.
Walk one player into the other, then into a wall.
You should see In a Server & Clients test with 2 clients, the two characters walk through each other but not through the scrap stacks or the shop walls.
Start a drill and stand still in the crawler's path.
You should see During a drill the crawler walks straight through a player standing in its way, and still bites when it is within reach.
Step 9 of 11
Drag the crate, with the server's permission
A DragDetector makes a part draggable with a mouse, a finger or a gamepad, with no input code7. Put one in the exhibit crate. DragStyle TranslatePlane drags along the ground plane. ResponseStyle Physical moves an unanchored part with constraint forces, so the crate still slides, hits things and stops at the end of its 8-stud rope.
Who may drag is a server decision. With RunLocally false, the default, the client only sends its input and the server performs the drag, and any permission or constraint function must live in a server script. Set PermissionPolicy to Scriptable and register a function that gets the player and returns true or false.
-- in ExhibitService, after the crate and its rope exist
local REACH = 12
local drag = Instance.new("DragDetector")
drag.DragStyle = Enum.DragDetectorDragStyle.TranslatePlane
drag.ResponseStyle = Enum.DragDetectorResponseStyle.Physical
drag.PermissionPolicy = Enum.DragDetectorPermissionPolicy.Scriptable
drag:SetPermissionPolicyFunction(function(player: Player, _part: BasePart?)
local character = player.Character
local root = if character then character:FindFirstChild("HumanoidRootPart") else nil
if root == nil or not root:IsA("BasePart") then
return false
end
return (root.Position - crate.Position).Magnitude <= REACH
end)
drag.Parent = crate
Build along
src/server/ExhibitService.luau
Add the block to
ExhibitService.start, runrojo serve, press Play and drag the crate.You should see Standing by the crate, you can drag it across the ground; it stops when the rope is straight and bumps into the hitch post.
Walk away and try again.
You should see From more than 12 studs away the crate does not move when you drag it.
Run a Server & Clients test with 2 clients and drag from each one in turn.
You should see A second client can drag the crate too, and both see the same motion.
To make dragging feel snappier, someone sets drag.RunLocally = true and keeps the permission function in ExhibitService. What happens?
drag.RunLocally = true
Press 1 to 4 to choose, Enter to check.
Step 10 of 11
Challenges
Level 1, Apprentice
Challenge
Turn the sign into a self-closing door with a servo, then restore it.
- Start from
- The game at milestone m06 (download)
Done means
- With ActuatorType Servo and TargetAngle 0, the sign swings back to the middle after a push
- ActuatorType is None again afterwards
Meet the criteria above, then record your own result. No test grades this check.
You want a turnstile that keeps spinning slowly forever. Which ActuatorType?
Press 1 to 4 to choose, Enter to check.
Level 2, Builder
Challenge
Watch ownership move between two clients, then pin the crate to the server.
- Start from
- The game at milestone m06 (download)
Done means
- In a two-client Server & Clients playtest, the crate's owner changes as players walk up to it
- After adding crate:SetNetworkOwner(nil) on the server, it stays with the server
- The call is removed again afterwards
Meet the criteria above, then record your own result. No test grades this check.
Level 3, Professional
Challenge
Add a second rope between two anchored pegs.
- Start from
- The game at milestone m06 (download)
- Grade it
- To grade work from an earlier milestone, apply your challenge changes to a checkout based on
m14-ship, which includes the Course Runner. In Studio, press Play, then rungame.ServerScriptService.RunGameTests:Invoke("physics", "physics-guide-rope")in the server command bar. Copy the pass code from Output.
Done means
- A RopeConstraint named GuideRope, Length 4, Visible = true, exists under Workspace.Yard.PhysicsExhibit
- Both of its attachments are on anchored BaseParts
- GuideRope is added as a separate RopeConstraint (do not rename CrateRope)
- challenges/physics.luau prints TEST PASS guide_rope
Step 11 of 11
Recap
Retiring the analogy
You no longer need “whoever holds the ball”. Each unanchored assembly is simulated by one machine. Clients near it usually own it for responsiveness; their simulated positions replicate to the server. Anything gameplay-critical is anchored or kept server-owned, and the server validates results instead of trusting the owner.
Recap
- Constraints join attachments: a hinge rotates around Attachment0's X axis (None, Motor or Servo), a rope is a maximum distance, a weld fixes two parts together.
- Welded parts form one assembly that moves and weighs as one; Massless and query-off keep decorative meshes out of gameplay.
- Unanchored parts are simulated by a nearby client by default; anything that decides gameplay is anchored or kept on the server with SetNetworkOwner(nil).
- Collision groups decide which solid parts block each other (register them on workspace, not PhysicsService); a DragDetector with RunLocally off lets the server decide who may drag.
Network ownership is whoever holds the ball, until the server can take the ball back at any time and always keeps anchored parts, and the holder is trusted with positions it reports, so a cheating holder can move the ball anywhere.
Queued for review