How do i create constant poison damage?

so uh, im quite confused on how to do constant poison damage, i kinda need help here, thanks!
note: what i mean by constant poison damage, is when somebody gets hit by a acid weapon or whatever, then he gets damaged, example: 1 damage, then right after, the poison deals constant damage

6 Likes

My method here is adding a server script and a boolValue to players to detect when they got constant poison damage :

Explanation

Adding a boolValue to player and name it “Poisoned” and the script inside player which detect whenever that boolValue is true or false.

If true then the script could damage players if necessary, you can even add a intValue named “Poison Damage” in the character if you want to custom poison damage or reduce poison damage if player drink some kind of potion

Else if false then the script will stop damaging player or you can reduce the poison damage int just like real life, poison doesn’t really gone at all once but reducing as the time goes on

And of course the attack must change the player’s boolValue in order to make player poisoned

And here’s the script if you need help with it!

Script

This script is for detecting whenever player is poisoned

local Poisoned == script.Parent:WaitForChild("Poisoned") -- you can change the name if you want
local PoisonDmg == script.Parent:WaitForChild("Poison Damage") -- you can also change the name

local Humanoid = script.Parent:WaitForChild("Humanoid")

Poisoned:GetPropertyChangedSignal("Value"):Connect(function()
   if Poisoned.Value == true then
       repeat
          if Poisoned.Value == true then
              task.wait(0.2) -- change how long you want poison to damage player for each time
              Humanoid:TakeDamage(PoisonDmg)
          else
              break
          end
       until Poisoned.Value == false
   elseif Poisoned.Value == false then
       return
   end
end)

I can’t help you with script that make player poisoned unless you provide me how do you want player to be poisoned. Like touched a poisoned part or cast spell on them

5 Likes

so uh, not really casting the spell, just touching a specific part, thats really just it

2 Likes

Then here it is :
Insert this script as a server script into a part that you want it to poison players

Local part = script.Parent

part.Touched:Connect(function(object)
    if object:FindFirstAncestorWhichIsA("Model") and object:FindFirstAncestorWhichIsA("Model"):FindFirstChildWhichIsA("Humanoid") then -- detect if the thing that touched the part is a player or not
       local Character = object:FindFirstAncestorWhichIsA("Model")
       local PoisonValue = Character:FindFirstChild("Poisoned")
       local PoisonDmg = Character:FindFIrstChild("Poison Damage")
       if PoisonValue and PoisonDmg and Character then
           PoisonValue = true
           PoisonDmg.Value = 1 -- damage of the poison.
           task.delay(HowLongDoIPoison?)   -- change to how long you want the poison to stay with the character
               PoisonValue.Value = false
               PoisonDmg.Value = 0
           end)
       end
    end
end)
4 Likes

ok, il be replying again if there are any bugs!

3 Likes

sorry, it doesnt work, i tried changing some stuff, it also did not work, i did this on a server script, i dont really know whats going on,

2 Likes

Did you properly name the boolvalue? And put them all inside the Charcater model include 2 of my scripts

1 Like

i named the boolvalue properly, i did both steps, is it possible to maybe change the script a bit?

1 Like

Yeah i forgot this part

       if PoisonValue and PoisonDmg and Character then
           PoisonValue = true -- here
           PoisonDmg.Value = 1 -- damage of the poison.
           task.delay(HowLongDoIPoison?)   -- change to how long you want the poison to stay with the character
               PoisonValue.Value = false
               PoisonDmg.Value = 0
           end)
       end

PoisonValue = true do absolutely nothing so. Change it to this PoisonValue.Value = true. Tell me if you found more erros that occur within my script

1 Like

i think it should work, im just really confused on what you mean by placing stuff in the Character Model

1 Like

image
This can help?
Poison Script - it’s the first script i sent
Poisoned - A boolValue to detect whenever player has been poisoned
Poison Damage - A int value to make poison damage

2 Likes

Yes, insert a 2 server scripts, 1 BoolValue and 1 IntValue then put it in StarterCharcater folder and name those stuff like the image i sent above

1 Like

i meant the constant damage to the part, how do i make it work

1 Like

Add a boolvalue and name it Poisoned in StarterCharacter
Add a intValue and name it PoisonDamage in StarterCharacter
Add a Script in StarterCharacter and paste this script in :

local Poisoned == script.Parent:WaitForChild("Poisoned") -- you can change the name if you want
local PoisonDmg == script.Parent:WaitForChild("Poison Damage") -- you can also change the name

local Humanoid = script.Parent:WaitForChild("Humanoid")

Poisoned:GetPropertyChangedSignal("Value"):Connect(function()
   if Poisoned.Value == true then
       repeat
          if Poisoned.Value == true then
              task.wait(0.2) -- change how long you want poison to damage player for each time
              Humanoid:TakeDamage(PoisonDmg)
          else
              break
          end
       until Poisoned.Value == false
   elseif Poisoned.Value == false then
       return
   end
end)

Add a script in the part that you want to poison player and paste this in

Local part = script.Parent

part.Touched:Connect(function(object)
    if object:FindFirstAncestorWhichIsA("Model") and object:FindFirstAncestorWhichIsA("Model"):FindFirstChildWhichIsA("Humanoid") then -- detect if the thing that touched the part is a player or not
       local Character = object:FindFirstAncestorWhichIsA("Model")
       local PoisonValue = Character:FindFirstChild("Poisoned")
       local PoisonDmg = Character:FindFIrstChild("Poison Damage")
            if PoisonValue and PoisonDmg and Character then
           PoisonValue.Value = true
           PoisonDmg.Value = 1 -- damage of the poison.
           task.delay(HowLongDoIPoison?)   -- change to how long you want the poison to stay with the character
               PoisonValue.Value = false
               PoisonDmg.Value = 0
           end)
       end
    end
end)

I apology if i didn’t get it right for you because i don’t really understand what you mean

1 Like

StarterCharacterScripts you mean?, i also have a problem, when i did everything, the poison did not activate, i did follow all steps tho

1 Like

The problem with the script is that this is invalid syntax:

The question mark is not good and it’s improper use of task.delay. This should be replaced with a wait(3).

1 Like

nope, i have already done that, no changes, also the “HowLongPoison?” thing means to type the specific number for the poison to last, i believe the problem comes from the 1st script. please scroll up and recheck for any problems on the 1st script.

1 Like

Oh, the problem with the 1st script is because it has == when defining a variable when it should be =.

1 Like

nope, it is not, i already fixed that. i believe the problem is the part “Humanoid:TakeDamage(PoisonDmg)”

PoisonDmg is not a number though. You mean PoisonDmg.Value?