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

How do I make the ability do dmg per second?

Asked by 5 years ago
Edited 5 years ago

I need to make it to where the ability does 3 dmg per second when a player a touching it

01--Server Script--
02local tween = game:GetService("TweenService")
03local casting = false
04 
05script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
06    if casting == true then return end
07    casting = true
08 
09    local iceSpikes = game.ReplicatedStorage.LightCage:Clone()
10    local dmg = 3
11    --Pre position
12    iceSpikes:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame)
13    iceSpikes.Parent = workspace
14    local endPositions = {Position = {}, Orientation = {}}
15    for i,v in pairs(iceSpikes.Spikes:GetChildren()) do
View all 49 lines...

1 answer

Log in to vote
1
Answered by 5 years ago

i think you overdid urself, theres a .Touched event. u need a debounce cuz it fires insanely

01local debounce=false
02script.Parent.Touched:Connect(function(hit)--hit is the obj
03if hit.Parent:FindFirstChildOfClass("Humanoid") and debounce==false then
04debounce=true
05hit.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(3)
06wait(2)
07debounce=false
08end
09 
10 
11 
12end)
0
what would I replace that with? Justingamer700 114 — 5y
0
Nvm lol. I didn't see the "script.Parent" Justingamer700 114 — 5y
0
Single player game? Because this sort of solution isn't multi-player compatible, just FYI. What I mean is one player touching the damage spike isn't stopping that player from taking damage for another 2 seconds, it stops that spike from damaging *anyone* over the next 2 seconds. That's not really what was asked for, and if this needs to work for more than one player, I would not consider it a solu EmilyBendsSpace 1025 — 5y
0
My instinct would be to do the damage cap at the receiving end, on a per-player basis. Instead of calling TakeDamage() directly, call up to a function in a server script that handles incoming damage and processes it once per second for each player, taking into account the max dmg allowed from each source. Then that script calls TakeDamage with the capped result. EmilyBendsSpace 1025 — 5y
0
..? its a serverscript EmbeddedHorror 299 — 5y
Ad

Answer this question