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

can someone help me change this r15 knockout script upon death?

currently to function this is what the script does

Character:WaitForChild("Humanoid").Died:connect(function()

does anyone know how I could change it to activate at a certain hp? For example, I'm trying to make a guy with 1000k hp, when he gets to 900 he ragdolls so people cant kill it after its ragdolls Thanks.

Edit:

Sorry for not going into enough detail, it's not for players, its for an enemy.

1 answer

✓ Accepted answer

Hello, Xeilot!

Try this: (Players)

local hp = 10 --This is the percent of the hp to enable... (Don't use %)

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(Character) --Detects player spawning
        Character.Humanoid.Changed:Connect(function() --Detects  changes on Humanoid
            if Character.Humanoid.Health < (hp/100 * Character.Humanoid.MaxHealth) then --Gets the player health and then tests if is lower than the percent of the max health
                --Do anything you want here...
            end
        end)
    end)
end)

Try this: (NPC)

Character = script.Parent --Place here a reference to the NPC's Humanoid

Character.Humanoid.Changed:Connect(function() --Detects  changes on Humanoid
	if Character.Humanoid.Health < (hp/100 * Character.Humanoid.MaxHealth) then --Gets the player health and then tests if is lower than the percent of the max health
                	--Do anything you want here...
		end
	end)

Good Luck with your games

3 comments

0

Give an explanation of what you're doing and why. Don't just post code for people, it doesn't help them in the long run.

0

ok... Done

0

can u help ^ i edited my original problem

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