Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make it so they cant be killed when they are sitting?

Asked by 5 years ago

Hello, I currently have this script which makes the Character sit when there health is at a certain point, how do I make it so they cant be killed when they are sitting? And is there a way to make it so a small message pops up on their screen that says " You have been downed" this message will go away in 5 seconds.



local plr = game.Players.LocalPlayer repeat wait() until plr.Character wait() local char = plr.Character char.Humanoid.Changed:connect(function() if char.Humanoid.Health <= 50 then char.Humanoid.Sit = true else print(char.Humanoid.Health) end end)

1 answer

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

In the weapon's script, you should check if the attacked player is sitting, and in the attacked player's weapon, check if they are sitting. If so, set the "Enabled" property of the tool to false. Something like this:

~~~~~~~~~~~~~~~~ --script will go in the top of the weapon's script. plr.Character.Humanoid.Changed:Connect(function(prop) if prop == "Sitting" then script.Parent.Enabled = false elseif not script.Parent.Enabled then script.Parent.Enabled = true end end)

--script will go wherever the weapon's usage function is if not attackedPlayer.Sitting then attackThePlayer(attackedPlayer) else return end ~~~~~~~~~~~~~~~~~

Ad

Answer this question