How to make workspace:GetPartBoundsInBox ignore/not return anything with an instance of a specific name?

I am creating a fighting game, and for one of the moves, I use :GetPartBoundsInBox for the hitbox. (I normally use client hitboxes but cant due to it being attached to a server object and it’s just easier.) The move itself works fine, but the problem comes when I try to make it ignore players with iframes. (Iframes are detected by looking for an instance named “IFrame” in the character. May be insecure, but it gets the job done easily.) The way I normally make it ignore iframes is to return end so it cancels the damage part of the script, but this certain script works differently, so it ends up breaking the rest of it that way. So is there anyway to just make the :GetPartBoundsInBox ignore anything that’s parent has an instance named “IFrame” in it? I’ve heard of overlap params whitelist, but I don’t know how I would make it whitelist anything with the parent having that instance.

Heres the script for the move, I doubt it matters though.

local remote = game:GetService('ReplicatedStorage').Remotes.Attacks.Sp.Barrage
local cs = game:GetService('CollectionService')
local reusedFunctions = require(game:GetService('ReplicatedStorage').Modules.ReusedFunctions)
local tweenService = game:GetService("TweenService")

remote.OnServerEvent:Connect(function(player)
	if not cs:HasTag(player, "barrageCooldown") and not player.Character:FindFirstChild('Stun') and player.Values.Stand.Value == "Sp" then --Preventing stand, cooldown, stun, and range hackers.
		cs:AddTag(player, "barrageCooldown")		
		cs:AddTag(player, "CantAttack")	
		task.delay(20, function()--Subtract based on windup
		cs:RemoveTag(player, "barrageCooldown")
		end)
		
		local standModel = game:GetService('ServerStorage').Models.Sp.SpHumanoidRig:Clone()
		standModel.Parent = workspace.Storage.Objects
		standModel.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3.5)
		game.Debris:AddItem(standModel, 5.05)
		local barrageAnim = standModel.StandHumanoid:LoadAnimation(standModel.Animations.Barrage)
		barrageAnim:Play()
		for _, v in pairs(standModel:GetDescendants()) do
			if v:IsA('BasePart') or v:IsA("BaseMesh") then
				if v.Name ~= "HumanoidRootPart" then
					v.Transparency = 1
					tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 0}):Play()
					local highlight = Instance.new('Highlight', standModel)
					highlight.FillTransparency = 0
					highlight.OutlineTransparency = 1
					highlight.FillColor = Color3.new(1, 1, 1)
					tweenService:Create(highlight, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FillTransparency = 1}):Play()
					game.Debris:AddItem(highlight, .4)
				end			
			end
		end
		local summonSound = Instance.new("Sound", standModel.HumanoidRootPart)
		summonSound.SoundId = "rbxassetid://6938611571"
		summonSound.Volume = .5
		summonSound:Play()
		game.Debris:AddItem(summonSound, 2)
		tweenService:Create(standModel.HumanoidRootPart, TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = standModel.HumanoidRootPart.CFrame * CFrame.new(0,0,-8)}):Play()
		local stopBarrage = false
		local hitCount = 0
		task.delay(3, function()
			stopBarrage = true
		end)
		local oraSound = Instance.new("Sound", standModel.HumanoidRootPart)
		oraSound.SoundId = "rbxassetid://6678126154"
		oraSound.Volume = .5
		oraSound:Play()
		game.Debris:AddItem(oraSound, 3.3)
		local anim = Instance.new('Animation', standModel.HumanoidRootPart)
		anim.AnimationId = "rbxassetid://12295728412"
		repeat
			hitCount += 1
			local op = OverlapParams.new()
			local hitContents = workspace:GetPartBoundsInBox(standModel.HumanoidRootPart.CFrame * CFrame.new(0,0,-3), Vector3.new(5,6,5), op)
	
			local canTouch = true
			for _, v in pairs(hitContents) do
				local char = v.Parent
				
				if char:FindFirstChild('Humanoid') and canTouch and char ~= player.Character then
					canTouch = false
					local hit = v
					if not char:FindFirstChild('IFrame') then
						if not hit.Parent:FindFirstChild('Blocking') then
							hit.Parent.Humanoid:TakeDamage(.7 * hit.Parent.Values.DefenseMultiplier.Value)
							local stun = Instance.new("BoolValue", hit.Parent)
							stun.Name = "Stun"
							if hitCount == 27 then
								game.Debris:AddItem(stun, 1)	
							else
								game.Debris:AddItem(stun, .3)	
							end						
							local hitSound = Instance.new("Sound", standModel.HumanoidRootPart)
							hitSound.SoundId = "rbxassetid://8503773812"
							hitSound.Volume = .25
							hitSound:Play()
							game.Debris:AddItem(hitSound, .8)	
							local animtrack = hit.Parent.Humanoid:LoadAnimation(anim):Play()

						else
							hit.Parent.Humanoid:TakeDamage(.15)
							local hitSound = Instance.new("Sound", standModel.HumanoidRootPart)
							hitSound.SoundId = "rbxassetid://3041192327"
							hitSound.Volume = .25
							hitSound:Play()
							game.Debris:AddItem(hitSound, .4)
						end			
						hit.Parent.HumanoidRootPart.CFrame = standModel.HumanoidRootPart.CFrame * CFrame.new(0,0,-3.5) * CFrame.Angles(0,math.rad(180), 0)
					end	
				end
			end
		task.wait(.1)
		until stopBarrage
		
		local barrageAnimFinish = standModel.StandHumanoid:LoadAnimation(standModel.Animations.BarrageFinisher)
		barrageAnimFinish:Play()
		local lastOraSound = Instance.new("Sound", standModel.HumanoidRootPart)
		lastOraSound.SoundId = "rbxassetid://6186280987"
		lastOraSound.Volume = .25
		lastOraSound.TimePosition = .5
		lastOraSound:Play()
		game.Debris:AddItem(lastOraSound, 3)
		task.wait(.55)
		local op = OverlapParams.new()
		local hitContents = workspace:GetPartBoundsInBox(standModel.HumanoidRootPart.CFrame * CFrame.new(0,0,-3), Vector3.new(5,6,5), op)
		
		local canTouch = true
		for _, v in pairs(hitContents) do
			local char = v.Parent
			if char:FindFirstChild('Humanoid') and canTouch and char ~= player.Character  then
				canTouch = false
				local hit = v
				if hit.Parent:FindFirstChild('IFrame') then return end
				if not hit.Parent:FindFirstChild('Blocking') then
					hit.Parent.Humanoid:TakeDamage(5 * hit.Parent.Values.DefenseMultiplier.Value)
					local stun = Instance.new("BoolValue", hit.Parent)
					stun.Name = "Stun"
					game.Debris:AddItem(stun, .3)								
					local hitSound = Instance.new("Sound", standModel.HumanoidRootPart)
					hitSound.SoundId = "rbxassetid://8701825353"
					hitSound.Volume = .25
					hitSound:Play()
					game.Debris:AddItem(hitSound, .8)	
					local animtrack = hit.Parent.Humanoid:LoadAnimation(anim):Play()
					local bv = Instance.new('BodyVelocity', hit.Parent.HumanoidRootPart)
					bv.Velocity = standModel.HumanoidRootPart.CFrame.LookVector * 70
					bv.MaxForce = Vector3.new(99999,99999,99999)
					game.Debris:AddItem(bv, .4)
					local hitVFX1 = game:GetService('ReplicatedStorage').VFX.HeavyVFX1:Clone()
					hitVFX1.Parent = workspace.Storage.Effects
					hitVFX1.CFrame = hit.Parent.Torso.CFrame
					local hitVFX1Weld = Instance.new('WeldConstraint', hitVFX1)
					hitVFX1Weld.Part0 = hit.Parent.Torso
					hitVFX1Weld.Part1 = hitVFX1
					for _, v in pairs(hitVFX1:GetDescendants()) do
						if v:IsA('ParticleEmitter') then
							v:Emit(5)
						end
					end
					game.Debris:AddItem(hitVFX1, 2)
				else
					hit.Parent.Humanoid:TakeDamage(1)
					local hitSound = Instance.new("Sound", standModel.HumanoidRootPart)
					hitSound.SoundId = "rbxassetid://9089408772"
					hitSound.Volume = .25
					hitSound:Play()
					game.Debris:AddItem(hitSound, .4)
				end		
			end
		end
		task.wait(.4)
		for _, v in pairs(standModel:GetDescendants()) do
			if v:IsA('BasePart') or v:IsA("BaseMesh") then
				if v.Name ~= "HumanoidRootPart" then
					tweenService:Create(v, TweenInfo.new(.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Transparency = 1}):Play()	
					local highlight = Instance.new('Highlight', standModel)
					highlight.FillTransparency = 0
					highlight.OutlineTransparency = 1
					highlight.FillColor = Color3.new(1, 1, 1)
					tweenService:Create(highlight, TweenInfo.new(.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FillTransparency = 1}):Play()
					game.Debris:AddItem(highlight, .2)
				end			
			end
		end
		game.Debris:AddItem(standModel["Right Arm"].RightGlove.Aura, .3)
		game.Debris:AddItem(standModel["Left Arm"].LeftGlove.Aura, .3)
		
		local unsummonSound = Instance.new("Sound", standModel.HumanoidRootPart)
		unsummonSound.SoundId = "rbxassetid://6938611595"
		unsummonSound.Volume = .5
		unsummonSound:Play()
		anim:Destroy()
		cs:RemoveTag(player, "CantAttack")
	end--//Exploit Check End
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Simply make it so when it touches an I frame it will simply do something like this

—other code—
if touched.Parent.iframe then
print(“Touched IFrame”)
Elseif 
—other code—

By the way I’m not a programmer so this is just an example, what I did is it checked if there’s the IFrame and if there is then print something, printing in this case would be useless, and then there’s the other code you have, and note, the script I made was only an example, you will have to adapt it to your script

I have tried this before and for some reason, it still breaks the script. That’s why I’m trying to make it be completely ignored by the :GetPartBoundsInBox.

Then idk, sorry I’m not a programmer, but I did what I could, hope you solve this problem

Yeah, It’s no problem, thank you!

1 Like

Nevermind I fixed it. I just had to make it check for the instance inside the other checks I ran for an i, v pair loop, which for some reason I haven’t done before.

Good for you! I’m happy you were able to solve the problem :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.