DragonYTPastesWork

MainScript - Obby Tutorial

Mar 2nd, 2021 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. local Obby = require(script.Parent.ObbyModule)
  2. local Checkpoints = workspace:WaitForChild("Checkpoints"):GetChildren()
  3.  
  4. Obby.Setup()
  5.  
  6. game.Players.PlayerAdded:Connect(function(player)
  7.     local cp = Instance.new("IntValue", player)
  8.     cp.Name = "CurrentCheckpoint"
  9.     cp.Value = 0 -- Current checkpoint will be spawn
  10.    
  11.     local character = player.CharacterAdded:Wait()
  12.     local humanoid = character:WaitForChild("Humanoid")
  13.    
  14.     humanoid.Died:Connect(function()
  15.         Obby.TeleportPlayer(player)
  16.     end)
  17.    
  18.     for _, Checkpoint in pairs(Checkpoints) do
  19.         Checkpoint.Touched:Connect(function(hit)
  20.             Obby.CheckpointTouched(hit, Checkpoint.CPNum.Value)
  21.         end)
  22.     end
  23. end)
Add Comment
Please, Sign In to add comment