local parent = script.Parent
local pipe = script.Parent["DISTORTION'S STAFF"]
local colorRNG = math.random(1,5)
local explosion = script.Parent.Explosion
--Sounds
local sound1 = explosion["Scary Sound"]
local tableofNames = {["Explosion"] = true,
["shockwave"] = true,
["invispart"] = true,
["INVISIBLEBOTTOM"] = true,
["PipeSmash"] = true,
["DISTORTION'S STAFF"] = true
}
while true do
for i = 1,25 do
pipe.Transparency = pipe.Transparency - 0.04
task.wait(0.01)
end
--Creating Beam
task.wait(0.25)
pipe.Transparency = 0
local debounce = false
local attachment = Instance.new("Attachment", pipe)
local vectorForce = Instance.new("VectorForce", pipe)
vectorForce.Parent = parent
vectorForce.ApplyAtCenterOfMass = true
vectorForce.Enabled = false
vectorForce.Attachment0 = attachment
local allignPosition = Instance.new("AlignOrientation", pipe)
allignPosition = attachment
local lookVector = pipe.CFrame.LookVector
local debounce = false
for i = 1,500 do
pipe.Anchored = false
parent.PrimaryPart.Anchored = false
vectorForce.Enabled = true
pipe.Velocity = lookVector * 185
pipe.Touched:Connect(function(Part)
if debounce == false then
print(Part.Name)
debounce = true
if Part.Name == tableofNames[(tableofNames)] then
elseif Part.Name and not tableofNames[(tableofNames)] then
local pipeexplosion = explosion:Clone()
pipeexplosion.Parent = workspace
pipeexplosion.Position = pipe.Position
pipeexplosion.Script.Enabled = true
pipeexplosion.ColorScript.Enabled = true
sound1:Play()
pipe:Destroy()
end
end
end)
task.wait(0.01)
end
parent:Destroy()
task.wait(1234567898765434567654345676543)
end
For context, I’m trying to make a part that collides with another part and explodes. That part works, however I want it so that the part (pipe
) cannot trigger the function from certain part names.
In other words, it’s this line of code that I’m having trouble with.
pipe.Touched:Connect(function(Part)
if debounce == false then
print(Part.Name)
debounce = true
if Part.Name == tableofNames[(tableofNames)] then
elseif Part.Name and not tableofNames[(tableofNames)] then
local pipeexplosion = explosion:Clone()
pipeexplosion.Parent = workspace
pipeexplosion.Position = pipe.Position
pipeexplosion.Script.Enabled = true
pipeexplosion.ColorScript.Enabled = true
sound1:Play()
pipe:Destroy()
end
end
end)
Here’s what’s wrong, it’s not printing any errors in the code but when I load the game, the part explodes on the parts I specifically blacklisted from their names from tableofNames
, which is not what I want. I do not know what I’m doing wrong and I’ve also tried multiple attempts to solve the problem, but they have failed so now I’m asking for help because of that part. If anyone would like to help, please do! I’d greatly appreciate it!