i want to make a 2 player obby for roblox
- User
i want to make a 2 player obby for roblox
Assistant
I'd be happy to help you create a 2-player obby for Roblox! Here's a simple script to get you started with the basic structure:
-- 2-Player Obby Script for Roblox -- Create checkpoints for players local checkpoints = {} -- Set up player spawn points local function setupSpawnPoints() local spawn1 = Instance.new("SpawnLocation") spawn1.Position = Vector3.new(0, 5, 0) spawn1.Name = "Player1Spawn" spawn1.Parent = workspace local spawn2 = Instance.new("SpawnLocation") spawn2.Position = Vector3.new(5, 5, 0) spawn2.Name = "Player2Spawn" spawn2.Parent = workspace end -- Create a checkpoint system local function createCheckpoint(position, number) local checkpoint = Instance.new("Part") checkpoint.Position = position checkpoint.Size = Vector3.new(6, 1, 6) checkpoint.Anchored = true checkpoint.CanCollide = true checkpoint.BrickColor = BrickColor.new("Bright green") checkpoint.Name = "Checkpoint" .. number checkpoint.Parent = workspace -- Add checkpoint to our table checkpoints[number] = checkpoint -- Create checkpoint trigger local trigger = Instance.new("TouchTransmitter") trigger.Parent = checkpoint checkpoint.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then -- Save player's checkpoint player:SetAttribute("LastCheckpoint", number) end end) end -- Handle player deaths game.Players.PlayerAdded:Connect(function(player) player:SetAttribute("LastCheckpoint", 0) player.CharacterAdded:Connect(function(character) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() wait(2) local lastCheckpoint = player:GetAttribute("LastCheckpoint") if lastCheckpoint > 0 then local checkpoint = checkpoints[lastCheckpoint] character:MoveTo(checkpoint.Position + Vector3.new(0, 5, 0)) end end) end) end) -- Create some obstacles local function createObstacles() -- Example obstacle: moving platform local platform = Instance.new("Part") platform.Size = Vector3.new(8, 1, 8) platform.Position = Vector3.new(20, 5, 20) platform.Anchored = true platform.BrickColor = BrickColor.new("Really red") platform.Parent = workspace -- Make the platform move spawn(function() local startPos = platform.Position while true do for i = 0, 10, 0.1 do platform.Position = startPos + Vector3.new(0, math.sin(i) * 5, 0) wait(0.05) end end end) end -- Initialize the obby local function init() setupSpawnPoints() -- Create some checkpoints createCheckpoint(Vector3.new(10, 5, 10), 1) createCheckpoint(Vector3.new(30, 5, 30), 2) createCheckpoint(Vector3.new(50, 5, 50), 3) createObstacles() end init()Would you like me to explain how this code works or help you customize specific aspects of your 2-player obby?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.