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

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

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

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

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