Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am trying to make a custom death, but keeping them from death seems to not work?

The goal is to have a script that keeps you from doing the classic roblox OOF that reloads your character. The rest is handled by another script, but it would seem that if something does enough damage you will fully die anyway, why is this?

repeat wait(2) until game.Loaded
game.Players.PlayerAdded:Connect(function(Player)
	local Char = workspace:FindFirstChild(Player.Name)
	while true do
		wait()
		Char.Humanoid.HealthChanged:Connect(function()
			if Char.Humanoid.Health <= 2 then
				Char.Humanoid.Health = Char.Humanoid.MaxHealth
			end
		end)
	end
end)

5 comments

0

Try out Player:LoadCharacter

0

That is the opposite of what I am trying to do, reloading the character is what I am trying to avoid.

0

So do you want to die at all in the game? or not

0

Not quite, I have a custom death, where it replaces your health and teleports you. Mainly because death breaks a script that is important, so I have to keep the character at the first joined state.

0

so do you have a custom health?

1 answer

If you have a custom health system, try this:

local Players = game:GetService("Players")
local function onCharacterAdded(char)
    char:WaitForChild("Humanoid").HealthChanged:Connect(function()
         char.Humanoid.Health = char.Humanoid.MaxHealth -- every time health is changed, set it to maxx
    end)
end
Players.PlayerAdded:Connect(function(p) p.CharacterAdded:Connect(onCharacterAdded) end)

If this helps, please mark as a solution. Metatable out!

This discussion is preserved as it was. New answers, comments, and votes are closed.