PLEASE HELP! it wont detect if the thing it hits is from the wall folder

ive been stuck doing this script for 2 hours, i cannot figure out, HOW TO GET IT TO DETECT IF IT HITS A PART FROM THE FOLDER:sob: :sob: :sob:

hitter.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			local wall = game.Workspace:WaitForChild("wall")
			local partsss = wall:FindFirstChild("Part")
			local wallhit = hit.Parent:FindFirstChild("partsss")
			
			if hit.parent == partsss and hit.Parent.Name ~= plr.Name and not hitOnce then
				print(partsss)
				print(hit)
				hitOnce = true
				hitter.BrickColor = BrickColor.Green()
				```
1 Like

ive also tried this

part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild(ā€œHumanoidā€)
local wall = game.Workspace:WaitForChild(ā€œwallā€)
local isPartOfWall = false

for _, part in wall:GetChildren() do
    if hit.Parent == part then
        isPartOfWall = true
        break
    end
end

if isPartOfWall and hit.Parent.Name ~= plr.Name and not hitOnce then
    print(hit.Parent)
    print(hit)
    hitOnce = true
    part.BrickColor = BrickColor.Green()
elseif hum and hit.Parent.Name ~= plr.Name and not hitOnce then
    hum:TakeDamage(damage)
    print(hit.Parent)
    hitOnce = true
    part.BrickColor = BrickColor.Green()
end

end)

if part:IsDescendantOf(wallFolder) then
   print("Part is in folder")
end
local hum = hit.Parent:FindFirstChild("Humanoid")
			local wall = game.Workspace:WaitForChild("wall")
			local partsss = wall:IsDescendantOf(wall)
			local wallhit = hit.Parent:FindFirstChild("partsss")
			
			if hit.parent == partsss and hit.Parent.Name ~= plr.Name and not hitOnce then
				print(partsss)
				print(hit)
				hitOnce = true
				hitter.BrickColor = BrickColor.Green()

i may have messed up somewhere??

if hit.Parent:IsDescendantOf(wall) and hit.Parent.Name ~= plr.Name and not hitOnce then
				print(partsss)
				print(hit)
				hitOnce = true
				hitter.BrickColor = BrickColor.Green()

tried a different way not work

Maybe it does detect that its from the folder but the if statement somehow fails because of the other checks?
from what i’ve seen it checks when part is touched by a player

but then if it is a player then the if statement fails

i dont really understand what your code tbh so i dont really know

omg… i copied and pasted hit.Parent.Name ~= plr.Name so i could make sure it doesnt hit the player but didnt notice it also checks for the player name in it

wait tried to remove it doesnt work still…

Is both parts anchored? If yes, then that’s the issue (one of either touching parts needs to be unanchored)

but how would that work? both the wall and hitbox needs to be anchored since their walls and hitboxes, also i did try it on un anchoring the hitbox but it just falls thru the floor :sob:

use workspace:GetPartsInPart()!!!

if hit.parent == workspace:GetPartsInPart(wall:GetChildren()) s

so i did this, uhm did i mess up? :sob:

that’s not how you’re supposed to use it…- it’s like raycast, you should read the documentary or… watch a tutorial… it gives you a table with what objects is touching the object

local OverlapParameters = OverlapParams.new()
OverlapParameters.FilterType = Enum.RaycastFilterType.Exclude
OverlapParameters:AddToFilter(WallPartorHitboxPartWhateverHere)

local Result = workspace:GetPartsInPart(WallPartorHitboxPartWhateverHere, OverlapParameters)

if #Result >= 1 then
print("it's touching sumthin..")

for i,v in Result do
print("It's Touching " .. v.Name)
end
end

There might be errors in this code since i wrote it on mobile, BUT, should be easy to figure out

And it’s different than Touching, you might need to run this on a loop, since it runs ONCE everytime

1 Like

ok so ive tried this! it works but not as intended, when ever it touches the part in the wall folder, it just says its a part, not the name of the part, and when i write it as v.parent.name it gives workspace not the folder : p ill try some other things

1 Like

ok i should have probably read more, and understood it xd

1 Like

pretty sure you can use :IsDescendantOf(Instance)

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