One world, many players
When multiplayer is on, everyone who opens your link is in the same world, each with their own character. Your scripts run for each player. Today you'll build a race and run it with the class.
1. Build the course
A start pad, a path with two jumps, a wide part at the end called Finish. Keep it short: about 20 seconds to run. Add a TextLabel on screen called Clock.
2. The finish line
Add a Script to Finish:
local finish = script.Parent
local clock = game:GetService("StarterGui"):FindFirstChild("Clock", true)
local started = os.clock()
local done = false
task.spawn(function()
while not done do
clock.Text = string.format("%.1f s", os.clock() - started)
task.wait(0.1)
end
end)
finish.Touched:Connect(function(other)
if done or not other:IsA("Player") then return end
done = true
local players = MultiplayerService:PlayerCount()
clock.Text = string.format("Finished in %.1f s, %d racing", os.clock() - started, players)
end)
Press Play and run it yourself. Does the clock stop on the pad?
3. Race someone
- Press Publish.
- In your world's settings, turn Multiplayer on.
- Send the link to a partner. They open it; you both press Play. You're in the same world.
4. Fix one thing
Something went wrong. It always does. A jump was too far, you could skip a section, the spawn was facing the wrong way. Fix one thing, publish again, race again.
Done when
- Your clock stops once, when you reach the finish.
- You've raced at least one other person in your world.
- You changed something because of that race.