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

Sit script on low health then get back up on higher health, any way?

Cant figure out how to make someone sit when they are on low health. Im a beginner at scripting but been building a pretty long time. Im trying to make it where when they get 10% health they will sit down and when they get 20% health they get back up. I tested it and it wont seem to work. Anything i should change?

game.Players.LocalPlayer.Character.Humanoid.HealthChanged:connect(function() game.Players.LocalPlayer.Character.Humanoid.Health / game.Players.LocalPlayer.Character.Humanoid.MaxHealth * 10 if game.Players.LocalPlayer.Character.Humanoid.Health/game.Players.LocalPlayer.Character.Humanoid.MaxHealth <= 0.1 then player.Humanoid.Sit = true if game.Players.LocalPlayer.Character.Humanoid.Health/game.Players.LocalPlayer.Character.Humanoid.MaxHealth >= 0.2 then player.Humanoid.Sit = false end end end)

Cant figure it out, if you want a idea of the script check out rrp2, when you lose damage u will go into a "injured" thingy which is what Im trying to script. Just ask someone to punch you or something in game.

Game im trying to make script like.

https://www.roblox.com/games/260606376/Realistic-Roleplay-2

2 comments

0

plz use block code, thats the only way i help people xD

0

my gosh im try gonna even try to read that without a code block

1 answer

✓ Accepted answer
game.Players.LocalPlayer.Character.Humanoid.HealthChanged:connect(function() game.Players.LocalPlayer.Character.Humanoid.Health / game.Players.LocalPlayer.Character.Humanoid.MaxHealth * 10 if game.Players.LocalPlayer.Character.Humanoid.Health/game.Players.LocalPlayer.Character.Humanoid.MaxHealth <= 0.1 then player.Humanoid.Sit = true if game.Players.LocalPlayer.Character.Humanoid.Health/game.Players.LocalPlayer.Character.Humanoid.MaxHealth >= 0.2 then player.Humanoid.Sit = false end end end)

I assume thats what you said (Above this text) The text below is wut i sed

while wait() do
local humanoid = game:GetService("Players").LocalPlayer:GetCharacter().Humanoid -- get dat characters humanoid
if humanoid.Health < 10 then -- if da characters health is less than ten den he sits O.O
	humanoid.Sit = true
elseif humanoid.Health >= 20 then -- other wise he stands O.O
	humanoid.Sit = false
end
end)

that loop is used as an auto updater so it detects when your health is low and all

2 comments

0

You can use the Changed event on a Humanoid instead of a loop.

0

^

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