Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Made by mdr721
- // date june 7, 2021
- // would like to thank yasingetstermedxd for the baseline checkpoint system
- function componentToHex(c) {
- var hex = c.toString(16);
- return hex.length == 1 ? "0" + hex : hex;
- }
- function rgbToHex(r, g, b) {
- return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
- }
- // put all the checkpoints in the game here
- const checkpoints = world.bricks.find(brick => brick.name === 'Checkpoint') //example
- // give above value to checkPointSystem function
- checkPointSystem(checkpoints) //example
- function checkPointSystem(checkpoint){
- onAndoff = true;
- pastPlayer = ['placeHolder']
- checkpoint.touching((player) => {
- username = player.username
- checkpoint.setColor(rgbToHex(255,0,0))
- console.log(pastPlayer.indexOf(username))
- if (pastPlayer.indexOf(username) == -1){
- player.spawnPosition = new Vector3(checkpoint.position.x,checkpoint.position.y + 5,checkpoint.position.z)
- player.setScore(player.score + 1)
- pastPlayer.push(username)
- }
- })
- checkpoint.touchingEnded((player) => {
- checkpoint.setColor(rgbToHex(0,255,0));
- })
- Game.on("playerLeave", (player) => {
- pastPlayer.splice(pastPlayer.indexOf(player.username))
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement