I’m creating a Vampire game where obviously you play as a Vampire, where only a set amount of things can kill you, otherwise you’ll just wake back up.
Currently, the way I’m doing this is setting the “Dead” Humanoid state type to false, but I’m unsure what the best way to decide whether something has killed you is.
Does anyone have any advice they could give me on what the best possible way to determine if something has killed you?
Are you asking for ways to check if something has killed you to prevent it or…?
If you are asking for easy ways to grant immortality, you could just add a BoolValue inside the character that is set to true whenever you want them to be “immortal.” And now in any scripts that do damage to players, just check if that BoolValue is set to false in order to do damage. Another hacky way to do this is just changing the name of the Humanoid to something else, but that might break some internal roblox scripts, so use it wisely.
If you’re just asking for ways to detect if someone has died, just use the .Died Event of Humanoids to determine if the player has died or not.
Yeah, but I am talking more about customization of death, like if you don’t want to use a health system. Humanoids were a good a few years back, when people were more just interested in simple npcs, but now they are just a bad idea for custom characters. Eventually, they will either be modified or outdated, whether the roblox dev community or roblox themselves do it, someone will replicate the humanoid:Move() with much more flexibility, and people will begin using animation controllers.
The easiest way to achieve this is to simply script in rules into your mechanics when they cause damage and disable reset, unless your character falls off the map or somehow loses their essential joints then they just simply won’t die unless you do :TakeDamage() and their health falls below zero.
Any mechanics you then script to damage the humanoid can then just have custom designed checks to see if they are a vampire etc.
If they don’t satisfy the requirements to die, then you could :FireClient some effect which causes them to fall to the ground knocked out temporarily for example. This can be done through animations, stunning or even by causing them to phase away.
I mean, you can do that, or, basically, for example, if there’s a gun taking the damage, make a table, and store players there like
local goddedplrs = {}
game.ReplicatedStorage.Damage.OnServerEvent(plr,humanoid, otherplr)
if goddedplrs[otherplr] == false then
humanoid:TakeDamage(20)
end
end)
gee… does nobody know that you can disable/enable humanoid states? and there’s a HumanoidStateType.Dead?
probably the best way instead of making the health a giant number or checking for every damage type if the humanoid is immortal… oh as @New_Item said :BreakJoints will kill the character (haven’t tested, but most likely), maybe that new RequiresNeck property will come in handy
Considering being a Vampire is a team or at least tagged as a certain set of players, you could program your game so that if they are a Vampire, then it will not deduct health. There’s no need to code immortality if your game doesn’t allow for harming these certain types of players.
As to answer your next question, to determine what killed you - there’s no built-in system for this you’d have to design your own kill tracker kind of system, whether it tracks who killed you, or an object killed you, etc. When you get hurt, tag that player to that object that harmed you, meaning that if they die, you now know what has killed you. Program a tagging/tracking system for this.
To determine when someone has died it is what @Complextic said, he is correct on that.
Hopefully I at least could answer some of your questions.
You can just disable the dead state on the server (wich will prevent it from respawning), and you can also do the same on the client to keep the player’s character from laying down. Or you could do the 0.01 health trick. I personally prefer the state way.
use math.huge not
10000000000000000000000000000000000000000000000000000000000000000000
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’