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

How would I make an area attack do damage to players over time?

Asked by 7 years ago
Edited 7 years ago

I have a part that has CanCollide == false and Anchored == true. I want it so that when a player is inside the part(in the area of effect), they will take damage every 1 second or so. I've tried multiple ways of going about this but they seem to never work. Is there a special way of doing this, can anyone help me out? Also, this has to do damage to multiple players over time not just one.

2 answers

Log in to vote
0
Answered by 7 years ago

If you already have a working script, you're going to want to create layers so that when the player moves through it they take damage, or a loop that damages any players within it for a certain amount of time. the loop, based on your question, should be wait(1).

0
Yes I know that it needs to be a loop for damage but I dont know how I would start making that bit of code. Wolf5429 15 — 7y
0
Decide to use the onion layering system. Make thin layers, as the player animation will, if the player remains there, make them touch a new layer if they just stand there. Attempt to make thin sheets in the Y axis and either X or Z. This way a player using R6 will suffer as much adage as one using R15. just my ten cents. billybobRAE 41 — 7y
Ad
Log in to vote
0
Answered by
uhTeddy 101
7 years ago

I made a script to put in the part, it has issues with it and doesn't work much but here it is.

01local Settings = {
02    ['TimeWait'] = .2, -- How long per run
03    ['Damage'] = 5, -- Damage per Run
04}
05 
06 
07local using = false
08 
09script.Parent.Touched:Connect(function(part) -- Part Touched
10    if game:GetService("Players"):GetPlayerFromCharacter(part.Parent) then -- Checks if the part is a player
11        if not using then
12            if part.Name == "Left Leg" or part.Name == "LeftFoot" or part.Name == "HumanoidRootPart" then
13                using = true
14                print("Using")
15                local humanoid = part.Parent:WaitForChild("Humanoid")
View all 34 lines...
0
Is there any simpler way of doing this? Also, this looks like a script to use during one touch of the part not a script for a part that needs to to damage over time. Wolf5429 15 — 7y
0
It does kill over time uhTeddy 101 — 7y
0
Well either way, I just tried the script and it doesn't work for my part for some reason. Wolf5429 15 — 7y

Answer this question