So, I'm making a projectile-based PVP game, and I recently found out i was a bit 'special' creating moving parts on the server, so I'm having moving parts replicate to all clients. Everything works, apart from the debounce, which allows each thing to be hit two times exactly before stopping itself, and I can't figure out why.
Here's the code:
---- DAMAGE FUNCTION ---- local dmgevent = game.ReplicatedStorage:WaitForChild("DamageEvent") function Damage(Caster, set, Victim, dmg, Part, SpellName)--(function(Player, set, Victim, Damage, Part, SpellName) if Caster.Name ~= Victim.Name then dmgevent:FireServer(set, Victim, dmg, Part, SpellName) end end -- THE EVENT -- dmgevent.Name = "DamageEvent" dmgevent.OnServerEvent:Connect(function(Player, set, Victim, Damage, Part, SpellName) MarkInfo(set, SpellName, Damage, script.BlankSpace, Part) bb(Victim.Head.CFrame, "-" .. Damage, Victim, function(item, dura) game.Debris:AddItem(item, dura) end) Mark(Player, function(item, dur) game.Debris:AddItem(item, dur) end, Victim.Humanoid) Victim.Humanoid:TakeDamage(Damage) print("Damaged" .. Victim.Name) end) --- ONTOUCH EVENT ---- local Done = {} local function Already(obj) for _, don in ipairs(Done) do if don == obj then return true end end return false end b.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= Player.Name then wait(.1) -- because its way too quick if Already(Hit.Parent.Name) == true then return end table.insert(Done, Hit.Parent.Name) print("Put " .. Hit.Parent.Name .. " in 'Done' table") Damage(Player, set, Hit.Parent, dmg, b, "BlastBullets") if math.random(1, 3) == 2 then Hit.Parent.Humanoid.Sit = true end end end)
b is the Projectile, and the only time Humanoid:TakeDamage is called in all of those functions is in the event (Victim.Humanoid:TakeDamage()). Everything does damage exactly two times, and I can't figure out how, so help would be appreciated! Thanks in advance.