Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it so this ignore forcefield?

I wanna make a weapon that can pierce forcefield.

function TakeDamage(humanoid, Damage)
	if not humanoid or not humanoid:IsA("Humanoid") or not Damage or not Player then
		return
	end
	local character = humanoid.Parent
	for i, v in pairs(character:GetChildren()) do
		if v:IsA("ForceField") then
			return
		end
	end
	local player = Players:GetPlayerFromCharacter(Character)
	if player then
		if IsTeamMate(Player, player) then
			return
		end
		CurrentMana.Value = CurrentMana.Value + (CurrentMana.MaxValue * 0.02)
	end
	TagHumanoid(humanoid, Player)
	humanoid:TakeDamage(Damage)
	UntagHumanoid(humanoid)
end

1 comment

0

May I suggest you just disable forcefields?

2 answers

✓ Accepted answer

remove

    for i, v in pairs(character:GetChildren()) do
        if v:IsA("ForceField") then
            return
        end
    end

That part searches through the character and detects if they have a forcefield. By removing it, you never check and go straight to damaging the player, which is what you want

Right now you are using humanoid:TakeDamage(Damage).

A quick easy way to damage a player with a forcefield on is humanoid.Health = humanoid.Health - Damage instead.

This discussion is preserved as it was. New answers, comments, and votes are closed.