1

What command would I need if I wanted a player to be teleported when they sleep in a bed?

sproouts____'s Avatar sproouts____3/18/23 3:51 pm history
1 emeralds 243 4
4/5/2023 7:04 pm
Luke_Sky_Walker's Avatar Luke_Sky_Walker
I want to make a command where when the player sleeps in a bed they are teleported to a certain area. I know I need a command block, and to use the /execute command, but I don’t understand anything beyond that. Could someone write me a template for that kind of command?
Posted by sproouts____'s Avatar
sproouts____
Level 19 : Journeyman Lemon
35

Create an account or sign in to comment.

4

Luke_Sky_Walker
04/05/2023 2:45 pm
Level 36 : Artisan Mlem Mlem Bat
Luke_Sky_Walker's Avatar
Alright, there is a fairly easy way to do this. Firstly you'll want to create a new objective using the scoreboard command (/scoreboard objectives add Example minecraft.custom:minecraft.sleep_in_bed). Next, you'll need to set up multiple command blocks so you can easily test for a player's score. Your first command block will be a repeat, always active, command block and it will hold the command "/execute as @p if score @p Example matches 1". Attach another command block to the repeat one facing the same direction as the first and make sure it is conditional, chain, and always active. In the second command block, add the command "/scoreboard players reset @p Example". The reason we do this is so that it will be able to run multiple times. If the score is greater than 1 then nothing will happen again unless we reset the score. After that, add a final command block. This command block will be used to run your command. Make sure it is also a conditional, chain, and always active command block and is facing the same direction. The command in it would look something like "/tp @p X Y Z" (Replace X Y Z with desired coords). After all of that, you should have a working system that checks to see if a player uses a bed and will teleport them accordingly and reset the score so they can be teleported again. You can also add repeaters to make it wait a bit longer before the TP. Hope this helps!
2
sproouts____
04/05/2023 3:19 pm
Level 19 : Journeyman Lemon
sproouts____'s Avatar
aahh thank u so much!
2
Luke_Sky_Walker
04/05/2023 7:04 pm
Level 36 : Artisan Mlem Mlem Bat
Luke_Sky_Walker's Avatar
No problem!
2
20w14infinite
03/18/2023 4:20 pm
Level 49 : Master Toast
20w14infinite's Avatar
I'm good with commands, but I genuinely have no idea
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome