Materials: a counter, a repeater, a camera view, a teleporter, a bed, a button, a game overlay, an item granter, and a popup. First, you should make the room with the bed. Infront of the bed, put down the button. Make the button invisible in-game, and make the button lead to a room where the dream will take place by putting a teleporter in the room.
Next, make it so that when the player is teleported there, the repeater starts. Next, put down the counter, make it invisible in-game, and make the counter target however long the dream can last. (Max Reptations: 100) Then, make it so that the repeater repeats the amount of times the number of the counter target is, and make it so that when the counter reaches the target, the counter resets, and the player is teleported back to the bed. Then, make the game overlay. It should be a button, and the button shouldn’t be visible until the player is teleported into the dream, and the button should be called: “Wake up”. When you press the button, you should teleport back to the bed. Make it so that when you teleport there, the counter resets, the repeater stops, the button disappears, and now you can use the item granter to gift the player 20 or more energy after waking up.
Now, you can focus on making the dream, and I can’t tell you what to do for the dream, so this is the farthest the guide will take you, other than the fact that you will be making this for every working bed, and you shouldn’t make each bed have the same dream, even though that will save memory, but then you won’t teleport back to where you were when you fell asleep, and you might be completely lost.