What do you want to achieve? I’m trying make this tool NOT kill player but instead “stop” damaging or “leave” them in <2% health, this is so my ragdoll function fires freely…
What is the issue? I can’t seem to make it work with the solution below.
What solutions have you tried so far? I tried to use Target.Health = math.max(1, Target.Health - Damage) however it does not seem to work… Solution derived from here.
Here is the part that deals damage to Target.
if Target:FindFirstChildOfClass("Humanoid") ~= nil then
Target:FindFirstChildOfClass("Humanoid"):TakeDamage(math.floor(Damage))
First, make all the people in the server in one team.
Then, make an anti-team script so the players won’t kill each other
Finally, you can make a fall damage script so people can take damage from fall damge.
Within your script, introduce a condition where it checks whether the Humanoid’s health is below the limit. Funnily enough, if you hit someone with a :TakeDamage() function and that goes beneath the threshold of your condition, you can immediately set their HP back to your desired value and the Humanoid won’t die, so long as there’s no delay within your script such as having it wait.
if Target:FindFirstChildOfClass("Humanoid") ~= nil then
Target:FindFirstChildOfClass("Humanoid"):TakeDamage(math.floor(Damage))
if Target:FindFirstChildOfClass("Humanoid").Health <= 2 then
Target:FindFirstChildOfClass("Humanoid").Health = 2
end
Additionally, you can just include a function that will simply not deal damage to the player if they’re at or beneath your current desired threshold.
if Target:FindFirstChildOfClass("Humanoid") ~= nil then
if Target:FindFirstChildOfClass("Humanoid").Health <= 2 then
Target:FindFirstChildOfClass("Humanoid").Health <= 2
else
Target:FindFirstChildOfClass("Humanoid"):TakeDamage(math.floor(Damage))
end
This works!! However how can i make so the player still damages the player when they’re ragdolled (usually below 35 health) but not make the target below 1 health of course.
This is how i reference if a player is ragdolled or not
if Target.HumanStates.Ragdolled.Value == true then -- Player is ragdolled
Follow the same principle and add a check for the Ragdolled value. If it’s true, then do what you want it to. If it’s false, let the gun do what it wants!