Dying while a script is active stops the script

I want to make the script so that it does not stop working when you die

Dying while a script is active stops the script, resulting in the player not being able to perform attacks using a bool value set to false at the start of the script
boolvalue normally true

1 Like

Use this:

if <Character>:FindFirstChildWhichIsA('Humanoid') then
	if <Character>.Humanoid.Health > 0 then
		doThings()
	end
end

In other words, check if the player is alive before doing the animation

Let me know if this helped!

EDIT: If possible, put the script and the boolvalue in the playerGUI so it does not reset when the player is dead.

Ok Thank you so much I will try it

Does the script work?

hahaha place holder go brrrrr

What does doThings mean? I’m not sure if its a default roblox function or you are telling me to put what ever the script is supposed to do.
Also sorry if it takes a while to let you know if it works or not, cause I’m asking this for my scripter since he has no access to the devforum

Just do what you want to do. That was a placeholder.

yeah that’s what I thought as well so I told him, but he says that it doesn’t work.
He says that he already used it at the start, but the problem happens when you die after it checks

it ain’t work sad. Also srry i didn’t know what placeholder meant

Sorry for the late reply. use the if around the loadanimations part, not the player spawn.
Placeholder basically means [insert text here].

Ok I’ll tell him to try that; thx! I’ll let you know if it works or not

yeah it still doesn’t work for some reason

local char = script.Parent
char.Humanoid.Died:Connect(function()

local value = Instance.new(“BoolValue”,char)
value.Name = “Dead”

game.Debris:AddItem(value,5)
end)
this is the script that sets the variable “dead” is what he says

put the variable in PlayerGui, otherwise the value will get deleted when the player respawns.

He says he wants it deleted because the code after it is to check if they are dead, and if they are dead, then do that or that.

I don’t think this can be solved, sorry for wasting time.
Also just for clarification do you need more parts of the script?

Can he upload all script related to the problem, along with the explorer? Thanks.

it wasn’t what fixed it, but we still used it in our code! thx for your help
We fixed it finally!

1 Like

Wow, nice! Sorry I couldn’t help more. :confused:

No, it’s fine because your script was used for the animation. It was really helpful; thx