Advertisement
Mdr721

Checkpoint System V2 bh

Jun 8th, 2021 (edited)
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Made by mdr721
  2. // date june 7, 2021
  3.  
  4. // would like to thank yasingetstermedxd for the baseline checkpoint system
  5.  
  6. function componentToHex(c) {
  7.   var hex = c.toString(16);
  8.   return hex.length == 1 ? "0" + hex : hex;
  9. }
  10.  
  11. function rgbToHex(r, g, b) {
  12.   return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
  13. }
  14.  
  15.  
  16. // put all the checkpoints in the game here
  17.  
  18. const checkpoints = world.bricks.find(brick => brick.name === 'Checkpoint') //example
  19.  
  20. // give above value to checkPointSystem function
  21. checkPointSystem(checkpoints) //example
  22.  
  23.  
  24.  
  25.  
  26. function checkPointSystem(checkpoint){
  27.  
  28.   onAndoff = true;
  29.   pastPlayer = ['placeHolder']
  30.  
  31.    checkpoint.touching((player) => {
  32.       username = player.username
  33.      
  34.  
  35.         checkpoint.setColor(rgbToHex(255,0,0))
  36.        
  37.  
  38.         console.log(pastPlayer.indexOf(username))
  39.  
  40.          if (pastPlayer.indexOf(username) == -1){
  41.           player.spawnPosition = new Vector3(checkpoint.position.x,checkpoint.position.y + 5,checkpoint.position.z)
  42.            player.setScore(player.score + 1)
  43.            pastPlayer.push(username)
  44.            
  45.          }
  46.      
  47.      
  48.      })
  49.  
  50.   checkpoint.touchingEnded((player) => {
  51.     checkpoint.setColor(rgbToHex(0,255,0));
  52.  })
  53. Game.on("playerLeave", (player) => {
  54.   pastPlayer.splice(pastPlayer.indexOf(player.username))
  55. })
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement