I would like to code a game where if you reach zero health, instead of dying, you’d ragdoll or have disabled movement until you get revived through a proximity prompt or something. I also envision a bleeding out timer so you’d have 60 seconds from the start of your knock to die. How would I go about scripting that?
Quote from the ‘About #help-and-feedback:scripting-support’.
“Please do not ask people to write entire scripts or design entire systems for you.”
I’m not asking for someone to help me code the entire thing, as quoted in my original message, it mentions “How would I go about scripting that?”. I need some guidance on what scripts to use and where to put them and how to prevent death on 0 HP.
IntValue instead of the actual health.
Please specify that in your topic. This is news that you didn’t specify before.
Okay. How about the actual health? Should I leave it as a large number so they can’t physically die? And how would I be able to subtract the health lost. I know I need to use the Humanoid.HealthChanged event.
For example, when someone punches the player, it subtracts an amount from the “Health” Intvalue (created for every player when they join the game). It never subtracts actual health. When the Intvalue’s value < 1 then you ragdoll or whatever.
He’s asking how he’d go about scripting that…not for someone to write the entire script out.
You could either make all player’s health = math.huge (which will be infinite) or…what I think would be easier…is to code all your weapons to subtract from the value that @Zompocolypse was talking about instead of making it take away health.
Here I’ve done this before, you simply set HumanoidStateEnabled(“Dead”) to false, then have a script that detects when the player dies, when they do, play a dead animation/ragdoll, and set them in a stun until a certain time/hp is reached. Works like a charm.
Okay. I’ll give that a go and if I get stuck, I’ll reply to this thread with my issue.
Ah. Where would I put this line of code? StarterPlayerScripts?
Has to be a script inside of StarterCharacter scripts, so it refreshes each time the player resets. It has to be a server script as well.
Okay, I’ll give that a go. Thank you.
No problem, I was actually also stuck on this problem for far to long, a very simple solution for this problem though.
script.Parent.Triggered:Connect(function() print("triggered") local plrName = script.Parent.Parent.Parent.Name local player = game:GetService("Players")[plrName] local Humanoid = player.Character:WaitForChild("Humanoid", 5) print("revived "..player.Name) script.Parent.Downed.Value = false Humanoid.WalkSpeed = 16 end)
The proximity prompt isn’t being triggered for some odd reason. Is it due to the 0 health?
(the red bar is the hunger, the bar below is the health, which clearly indicates I’m dead)
Hmm, 2 questions, you set humanoidStateEnabled(“Dead”) to false right? And did you get this result by resetting? Because resetting doesn’t work to well sadly, as it does more than set the hp to 0, it also deletes some scripts within the character.
Ah. That makes so much sense. And yes the HumanoidStateEnabled(“Dead”) is implemented
I’ve done it without resetting, and now it respawns me for an odd reason.
Hmm, doesn’t look like you’re doing it on the server, that could be a reason.
The ProximityPrompt still isn’t triggering, and I have no idea why. (i didnt reset)