I have tried this, but only 1 random part in the group of 10 parts explodes, but I want so all 10 parts explode
local e = Instance.new("Explosion") wait(1) for i,part in pairs(workspace.ExplosivePartsGroup:GetChildren()) do e.Parent = part e.Position = part.Position e.BlastRadius = 5 e.BlastPressure = 100000 e.DestroyJointRadiusPercent = 1 end
I tried to do same thing but without in pairs loop but it says error in output:
Workspace.PartsExplodeScript:25: invalid argument #3 (Instance expected, got table)
Code:
local e = Instance.new("Explosion") local part = workspace.ExplosivePartsGroup:GetChildren() e.Parent = part e.Position = part e.BlastRadius = 5 e.BlastPressure = 100000 e.DestroyJointRadiusPercent = 1
You are instantiating a new explosion outside the loop, so the explosion only happens once and then gets parented to 10 different blocks, it needs to be in the loop for the explosion to happen 10 times on 10 different blocks
for i,part in pairs(workspace.ExplosivePartsGroup:GetChildren()) do local e = Instance.new("Explosion") e.Parent = part e.Position = part.Position e.BlastRadius = 5 e.BlastPressure = 100000 e.DestroyJointRadiusPercent = 1 end
For your second problem You need to read up on how GetChildren()
works, it returns a table, the table contains all instances of the parts you want to explode, so you have to use a for loop such as in pairs to loop through the instances and apply the explosion