I created a spell that explodes and deals damage based on who was in the explosion using the hit event. I want the players inside the explosion to take 15 damage but instead, they take infinite damage because the if statement on line 35 always goes through even when it should not.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local testSpell = ReplicatedStorage:WaitForChild("TestSpell") local demon_circle = ReplicatedStorage:WaitForChild("Assets").demon_circle testSpell.OnServerEvent:Connect(function(player, hit) local p = demon_circle:Clone() p.Parent = workspace p:SetPrimaryPartCFrame(hit) p.PrimaryPart.Anchored = true p.PrimaryPart.Orientation = Vector3.new(0, 0, 0) -- Rotate for i = 1, 90, 1 do p.PrimaryPart.Orientation = Vector3.new(0, i, 0) wait(.000001) end -- Explosion (Visual only) local e = Instance.new("Explosion") e.Parent = workspace e.Position = p.PrimaryPart.Position e.DestroyJointRadiusPercent = 0 e.BlastPressure = 0 e.BlastRadius = 7.5 hitList = {"Undefined"} local function damage_handler(character) local canDamage = false for i = 1, #hitList do wait(.0000001) --print(hitList[i]) if hitList[i] ~= character.Name then print("Has not been hit yet") table.insert(hitList, #hitList+1, character.Name) canDamage = true end end if canDamage then character.Humanoid:TakeDamage(15) end end e.Hit:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then --[[for _, name in pairs(hitList) do wait(.0000001) print(name) if name ~= hit.Parent.Name then table.insert(hitList, #hitList+1, hit.Parent.Name) hum:TakeDamage(15) end end--]] damage_handler(hit.Parent) end end) p:Destroy() end)