DragonYTPastesWork

ObbyModule - Obby Tutorial

Mar 2nd, 2021
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local Obby = {}
  2. local Checkpoints = workspace:WaitForChild("Checkpoints")
  3.  
  4. Obby.RespawnTime = 3
  5.  
  6. function Obby.Setup()
  7.     local SpawnL = Instance.new("SpawnLocation", workspace)
  8.     SpawnL.Neutral = true
  9.     SpawnL.Anchored = true
  10.     SpawnL.CanCollide = false
  11.     SpawnL.Enabled = true
  12.    
  13.     local Sp = Checkpoints:WaitForChild("Spawn")
  14.     SpawnL.CFrame = Sp.CFrame
  15.     SpawnL.Size = Sp.Size
  16.     SpawnL.TopSurface = "Smooth"
  17.     Sp:Destroy()
  18. end
  19.  
  20. function Obby.TeleportPlayer(player)
  21.     wait(Obby.RespawnTime)
  22.     player:LoadCharacter()
  23.     local character = player.Character
  24.     if player.CurrentCheckpoint.Value > 0 then
  25.         character.HumanoidRootPart.CFrame = Checkpoints:FindFirstChild(player.CurrentCheckpoint.Value).CFrame + Vector3.new(0, 5, 0)
  26.     end
  27. end
  28.  
  29. function Obby.CheckpointTouched(hit, cpNum)
  30.     if game.Players:FindFirstChild(hit.Parent.Name) then
  31.         if cpNum > game.Players:FindFirstChild(hit.Parent.Name).CurrentCheckpoint.Value then
  32.             game.Players:FindFirstChild(hit.Parent.Name).CurrentCheckpoint.Value = cpNum
  33.         end
  34.     end
  35. end
  36.  
  37. return Obby
Advertisement
Add Comment
Please, Sign In to add comment