Wrote a much more reliable version of the functions you were using.
Regardless of if these replacements do exactly what you had them doing previously, you can still sample code from damageWithinCircle for a much more reliable damage applier.
local nukeExploded = false
local distanceCap = 1000
local function damageWithinCircle(nukeCircle, playersToDamage)
for _, targetPlayer in pairs(playersToDamage) do
local targetCharacter = targetPlayer.Character
if targetCharacter then
local humanoid = targetCharacter:FindFirstChildOfClass("Humanoid")
if targetCharacter and targetCharacter.PrimaryPart and humanoid then
local relativeDistance = (targetCharacter.PrimaryPart.Position - nukeCircle.Center.Position).Magnitude
local relativeDamage = (distanceCap - relativeDistance) * 0.5
warn(relativeDistance, relativeDamage)
humanoid.Health = humanoid.Health - relativeDamage
if humanoid.Health <= 0 then
killTarget(targetCharacter)
elseif humanoid.Health <= 10 then
abilities.Parent.ChangeStatus:FireClient(targetPlayer, "Stun", 2.5)
end
end
end
end
end
nukeCircle.TouchEnded:Connect(function(hit)
local psuedoPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
if psuedoPlayer then
for index, player in pairs(playersToDamage) do
if player == psuedoPlayer then
table.remove(playersToDamage, index)
break
end
end
end
end)
nuke.Touched:Connect(function(hit)
if not nukeExploded then
nukeExploded = true
wait(3)
nuke:Destroy()
for _, v in pairs(script.Particles:GetChildren()) do
v.Parent = nukeCircle
end
damageWithinCircle(nukeCircle, playersToDamage)
wait(1.25)
nukeCircle:Destroy()
end
end)