Hello Im trying to make a weapon that other than deal normal damage it deals like a poison damage like one damage every second for 10 seconds
How do i make a weapon that poison?
1 answer
I don't know if you're asking for the whole gun script, or just the poison damage part. Due to this, I will link a video for making a working gun and I will go over the poison script.
In the part off the script where it will deal damage, so if the bullet successfully hit a player it will need to loop through it 10 times, once for every second. You can do this by saying
for i = 1 , 10 do
end
This will loop 10 times. Now we need the damage part, so at the start off the script we will declare a number variable called "Damage". This is just to make it easier to change. We also need the Humanoid declared.
local Damage = 1
local Humanoid -- Declare the humanoid in a different part off the code, it depends how you scripted the gun system on where this will be.
-- Other gun code here
for i = 1 , 10 do
end
-- Other gun code here
Now we need to actually damage the player, we can do this by running Humanoid.Health -= Damage, this way it takes damage and if it will be an amount to kill them, it will ignore the forcefield. We can also call Humanoid:TakeDamage(Damage). This way the player can't take damage if they got attacked while having the force field. This is the way I will use it.
So now, our poison code will look something like this:
local Damage = 1
local Humanoid -- Declare the humanoid in a different part off the code, it depends how you scripted the gun system on where this will be.
-- Other gun code here
for i = 1 , 10 do
Humanoid:TakeDamage(Damage)
end
-- Other gun code here
Finally, we need to add a wait(1). This is because it will instantly run this loop and deal the damage in one go. The final code should look like this:
local Damage = 1
local Humanoid -- Declare the humanoid in a different part off the code, it depends how you scripted the gun system on where this will be.
-- Other gun code here
for i = 1 , 10 do
Humanoid:TakeDamage(Damage)
wait(1)
end
-- Other gun code here
This poison script is ran on the server
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
uh i mean like a sword... im sorry i should say that before
but anyway lemme see
yeah it might be answering what i need but can i rename the damage variable right cause i alredy have one and if i dont rename it i think it will be the same damage as the base one
but anyway thanks dude
Its a simple thing, you just need to replace the damage part in the sword with that. There shouldn't be any difference really.
but if i do replace the script part with that that will only poison