The problem is that I want my attack to be able to deal damage to multiple targets but if I don't use a debounce then it will deal that damage like 50 times to each player, and if I use a debounce it will only damage one player. How would I make it so it can hit multiple targets while it also has a debounce?
I tried using a table so when a player gets hit their name gets puts inside the table, but I don't know what to do next
This is what the hit detection looks like right now:
ShockWave2.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local Table = {} table.insert(Table,game.Players:GetPlayerFromCharacter(hit.Parent))
You're on the right path with the table, now all you need to do is check if the player is in the table before damage. If the player is in the table, don't do damage, otherwise deal the amount you want. To go through the whole table we can use a for loop. This would make your code look like the following block:
local Table = {} -- Define the table first or else you will make a new one every hit. ShockWave2.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local found = false for i = 1, #Table do if Table[i] == hit.Parent.Name then found = true end end if found == false then table.insert(Table,game.Players:GetPlayerFromCharacter(hit.Parent).Name) humanoid:TakeDamage(30) found = true wait(3) for i = 1, #Table do if Table[i] == hit.Parent.Name then table.remove(Table, i) end end end end end)
This should now create debounces for separate players, however, I have no access to studio currently so I couldn't test. Feel free to tell me any errors and I will correct them for you.