1
What command would I need if I wanted a player to be teleported when they sleep in a bed?
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?
Create an account or sign in to comment.
4
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!
aahh thank u so much!
No problem!
I'm good with commands, but I genuinely have no idea