How do i detect if part touched another part that has bool value

what i mean by bool value is this

i want to make attack that can certain destroy parts only if it has bool value

of course i know where to start like



(attack is a part that should touch something)

what next should be

Use FindFirstChildWhichIsA() Instance | Documentation - Roblox Creator Hub

 if obj.Parent:FindFirstChildWhichIsA("BoolValue") and obj.Parent:IsA("BasePart") then 
   local val = obj.Parent:FindFirstChildWhichIsA("BoolValue")
   if val.Name == "CanBeDestroyed" and val.Value == true then 
   -- Your code goes here.
1 Like

If it’s just a single part, that doesn’t have any parents, you could do

 if obj:FindFirstChildWhichIsA("BoolValue") and obj:IsA("BasePart") then 
   local val = obj:FindFirstChildWhichIsA("BoolValue")
   if val.Name == "CanBeDestroyed" and val.Value == true then 
     -- Lets say you wanted to destroy the part, with making an explosion!
    local EXP ="Explosion")
    EXP.Parent = obj
    EXP.BlastRadius = 30
    EXP.Position = obj.Position
1 Like

part doesnt get destroyed for some reason

it used to get destroyed but now it doesnt

Are you sure that your part isnt in an another object?

doesnt work still

even if it doesnt i still appreciate your time thanks

Could be that you set the CanBeDestroyed to false. Either way I think its more efficient and easier to use Tags(Collection Service)

if im not wrong but there should be a pluggin that allows you to use tags much more easier