Not being able to hit certain part roblox studio

Hello, so i have this script and im trying to check if the part it hit name is “FireDebris” but for some reason its still being able to hit it

elseif hit:IsA("BasePart") then
			local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
			if ehum and ehum ~= player.Character.Humanoid then
				print("hit humanoid")
				local humanoid = hit.Parent:FindFirstChild("Humanoid")
				local FireDebris = game.ReplicatedStorage.FireRelease.FireDebris:Clone()
				FireDebris.Parent = workspace
				FireDebris.Position = ehum.Parent.HumanoidRootPart.Position
				local Explode = game.ReplicatedStorage.FireRelease.Explode:Clone()
				Explode.Position = ehum.Parent.HumanoidRootPart.Position
				Explode.Parent = workspace
				for i, v in pairs(Explode.AMain:GetChildren()) do
					v:Emit()
				end
				local FireHitSound = script.Parent.FlameHitSound:Clone()
				FireHitSound.Parent = FireDebris
				FireDebris.FlameHitSound:Play()
				Debris:AddItem(Explode, 3)
				Debris:AddItem(FireDebris, 5)
				bullet:Destroy()
				ehum:TakeDamage(damage)

			else
				if hit.Parent.Name ~= "FireDebris" or hit.Parent.Parent.Name ~= "FireDebris" then
					print("HitPart")
					local humanoid = hit.Parent:FindFirstChild("Humanoid")
					local FireDebris = game.ReplicatedStorage.FireRelease.FireDebris:Clone()
					FireDebris.Parent = workspace
					FireDebris.Position = bullet.Position
					local Explode = game.ReplicatedStorage.FireRelease.Explode:Clone()
					Explode.Position = bullet.Position
					Explode.Parent = workspace
					for i, v in pairs(Explode.AMain:GetChildren()) do
						v:Emit()
					end
					local FireHitSound = script.Parent.FlameHitSound:Clone()
					FireHitSound.Parent = FireDebris
					FireDebris.FlameHitSound:Play()
					Debris:AddItem(Explode, 3)
					Debris:AddItem(FireDebris, 5)
					bullet:Destroy()
				end

nvm, i fugured it out, LOL, srry abt that

1 Like

is it because you want it to equal FireDebris? Right now you have ~= which means not equal.

== would return true if the parent IS named “FireDebris”:

if hit.Parent.Name == "FireDebris" or hit.Parent.Parent.Name == "FireDebris" then

I noticed that

if hit.Name ~= "FireDebris" then 

this works, but when it touches it it just ends and doesnt contunue

I want it to only do the stuff if its the parts name is not equal to that, if it does touch a part thats named that, i want it to just not do anything and contunue, but after touching it, it doesnt do the code if it touches a part thats not named that. If it makes any sense

maybe change it to if hit:IsDescendantOf(game.Debris) == false then

Do you have the output for what happens?

That code just completly has a lot of errors…

Yeah, that code doesnt work at all

Yeah so if that doesn’t work, you could possibly parent the fire particles to a folder in workspace instead of just workspace, then use the same code except check if it is a descendant of it:

FireDebris.Parent = workspace.FireFolder

if hit:IsDescendantOf(workspace.FireFolder) == false then

THis works the exact same as my other script, it allow it to go through without touching it, but if it touches something after touching the FireDebris then it wont do anything

I don’t really see a reason in this portion of the code as to why it wouldn’t. I would recommend to debug you just print every part it hits that is a base part and comment out the rest:

If it hits the parts past the fire part, then it is a problem in this portion, but if it doesn’t hit the parts past it, then it’s a problem outside of this

elseif hit:IsA("BasePart") then
         print(hit.Name)
			--[[local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
			if ehum and ehum ~= player.Character.Humanoid then
				print("hit humanoid")

Well, FireDebris is a particle, what if i was able to not make it a base part, could i do that?

Is there anything i can do with the “contunue” function?

I’ll need to see a little more of your code to have a better understanding of what is going wrong. Important parts such as the event that connects this function and the rest of the if statement

Well can i just say that the ability is a fireball, And when it touches a part the ability explodes. But firedebris is sopposed to appear where it exploded and when the player touches it, they take damage. But, the fireball is able to touch the part that Holds the firedebris particle making it explode(which i dont want). I could just make it so that the part that holds the particle cant be touched, but then the player cant be damaged

So what is the desired sequence of events? You shoot the fireball, the fireball explodes, if a player touches the debris they take damage? I’m just confused on what the current sequence of events are and where the issue is taking place. Does it take place after the fireball explodes? Does it take place right when you shoot it?

The fire debris appears when the fireball explodes, and it stays in that spot for a bit

So the fireball stays where it’s at and doesn’t get deleted? Does the debris have any issues or do they work as intended?

No the fireball disappears, but the the debris replaces it, the after 3 seconds, the debris gets deleted, and the debris works as intended, but since the debris is touchable, if you shot a fireball, then shoot on again before the debris gets deleted, the fire ball disappears when touching the fire debris, but i dont want it to explode when touching it lmao, i kinda just want the fireball to ignore it and be able to go through the fire debris

Do you have a debounce anywhere? Also, did you try seeing if the hit function registers parts after hitting the firedebris by using a print(hit.Name)? If it’s able to ignore the firedebris but just doesn’t work afterwards either it’s not registering parts for some reason or there’s a delay in the hits it registers. Also I would recommend changing this if hit.Parent.Name ~= "FireDebris" or hit.Parent.Parent.Name ~= "FireDebris" then to this if hit.Parent.Name ~= "FireDebris" and hit.Parent.Parent.Name ~= "FireDebris" then because if one of those returns true but the other returns false then the statement will be satisfied and the code will run