2
I need MORE help
ok, I'm new in datapacks and I have a doubt, how would I make a victory system for my map?
I tried to create one where if the person died 3 times, his score would reset and it would show that he lost.
Then it worked, but for the winner I don't know how to do it.
who should win would be the last person to stay alive, without dying 3 times.
I tried to create one where if the person died 3 times, his score would reset and it would show that he lost.
Then it worked, but for the winner I don't know how to do it.
who should win would be the last person to stay alive, without dying 3 times.
10
I'd start by changing the order of commands so the title displays before your clear the scoreboard. This way you can have the title command check the scoreboard and display the "You win" and "You loose" titles to players by their number of deaths. I'd also reset all players' scores and clear all players' effects so the game is fully reset. I'd do it like this [assuming this runs as the player who died 3 times]:
title @s title ["",{"text":"You Lose","color":"red"}]
title @a[scores={Deaths=..2}] title ["",{"text":"You Win","color":"green"}]
scoreboard players reset @a Deaths
..2 means "up to 2", which means that every player except for the one with a score of 3 will see this title (in the case of a 1v1, that's 1 player). There are many ways to do this, but I think this is the simplest change to your code.
title @s title ["",{"text":"You Lose","color":"red"}]
title @a[scores={Deaths=..2}] title ["",{"text":"You Win","color":"green"}]
scoreboard players reset @a Deaths
..2 means "up to 2", which means that every player except for the one with a score of 3 will see this title (in the case of a 1v1, that's 1 player). There are many ways to do this, but I think this is the simplest change to your code.
But we are told that the winner should be the "the last person to stay alive, without dying 3 times". With this setup, only one player will have to die 3 times, and everyone other than the one player who died will be announced as a winner. The solution to this is to simply count how many players are remaining, and select the only player remaining when all of the others have died 3 times.
Command to start the game:
Commands to run during game:
Command to start the game:
scoreboard players add @a Deaths 0Commands to run during game:
scoreboard players set #PlayerCount Deaths 0execute as @a[scores={Deaths=..2}] run scoreboard players add #PlayerCount Deaths 1execute if score #PlayerCount Deaths matches ..1 run title @a[scores={Deaths=..2}] title ["",{"text":"You Win","color":"green"}]title @a[scores={Deaths=3..}] title ["",{"text":"You Lose","color":"red"}]execute if score #PlayerCount Deaths matches ..1 run scoreboard players reset @a Deathsscoreboard players reset @a[scores={Deaths=3..}] Deaths
I tested your command, but in all the parts that had [scores={Deaths=..2}] an error appeared in them
Huh, how strange, I think I've found our problem. There is nothing wrong with the commands themselves, but rather with how they are getting copied. Apparently there was an invisible character that you can't see when you go to copy off of the webpage, so when you paste it into the mcfunction file, it doesn't work. Hopefully, I fixed this problem, and it should work if you try again! :)
If it doesn't work, I need more details:
What is the error? Very hard to help fix the problem if I don't know what the problem is.
What Minecraft version are you using? The above commands are meant for 1.17.1, and may not work in older versions of the game.
Are you using any mods that could conflict with vanilla commands? If so, you might need to use /minecraft:command instead of /command.
Are there any other details you can think of giving me that might help me better understand what's going on?
If it doesn't work, I need more details:
What is the error? Very hard to help fix the problem if I don't know what the problem is.
What Minecraft version are you using? The above commands are meant for 1.17.1, and may not work in older versions of the game.
Are you using any mods that could conflict with vanilla commands? If so, you might need to use /minecraft:command instead of /command.
Are there any other details you can think of giving me that might help me better understand what's going on?
Ok ok, here's the thing, I think it's almost ok now, but since I put a /schedule for the command to be active always checking, it ends up repeating the "you win" command endless
The question is, how would I prevent this from happening?

The question is, how would I prevent this from happening?

I would run the function I gave only when any given player has died. You can do that with the commands given in this post. Something worth noting is that you are always going to win in a singleplayer environment because you are the only player(Unless you opened the world to LAN and invited some friends on that is).
EDIT: Having invisible character issue again with the new commands. Trying to fix
EDIT2: Fixed
EDIT: Having invisible character issue again with the new commands. Trying to fix
EDIT2: Fixed
scoreboard objectives add hasDied deathCountexecute if entity @a[scores={hasDied=1..}] run function path:to/above/functionscoreboard players reset @a[scores={hasDied=1..}] hasDiedView 1 more replies
you two are gods
