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

How do i make a weapon that poison?

Asked by 1 year ago

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

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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
0
uh i mean like a sword... im sorry i should say that before G4BR13L_progamer123 5 — 1y
0
but anyway lemme see G4BR13L_progamer123 5 — 1y
0
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 G4BR13L_progamer123 5 — 1y
0
but anyway thanks dude G4BR13L_progamer123 5 — 1y
View all comments (2 more)
0
Its a simple thing, you just need to replace the damage part in the sword with that. There shouldn't be any difference really. Jay123abc2 241 — 1y
0
but if i do replace the script part with that that will only poison G4BR13L_progamer123 5 — 1y
Ad

Answer this question