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?

2 Likes

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.

you might want to do

humanoid.maxhealth = "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
humanoid.health = "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
5 Likes

The best way to determine if someone died is Humanoid.Died

If you want more customization, I suggest using an animation controller and rewriting the roblox movement script. Then, you can still use animation and move your character. Here is the corescripts roblox uses to move the player: https://github.com/Roblox/Core-Scripts/blob/master/PlayerScripts/StarterPlayerScripts_NewStructure/RobloxPlayerScript/ControlScript.lua

Then, you can make your own died event and have more control over how the character dies.

1 Like

Disable the death state in the humanoid, then it is not possible to die unless :BreakJoints() is used, or the avatar falls.

1 Like

Might not solve the topic,
but why add a million zeros?

100000000000000000000000000000000000000

Here's another way, keep a local script in StarterCharacterScripts and insert this code:
  local character = script.Parent
  local humanoid  = character.Humanoid 

  humanoid.MaxHealth = math.huge
  humanoid.Health = math.huge

  print(humanoid.Health)  

Output for health :

image

This will print infinite, as the health.

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)

Put this script in StarterCharacterScripts

while true do
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
wait()
end
2 Likes

Or you can just put a humanoid in StarterPlayer and change it

Dont do that unless you want to change the humanoid majorly, adding a custom humanoid for just changing health is bad choice.

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

1 Like

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.

1 Like

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
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’