Hi guys!
I made a part that explodes This is the script inside that part
wait(3) local boom = script.Parent local explosion = Instance.new("Explosion") explosion.Parent = game.Workspace explosion.Position = boom.Position boom:Destroy()
Okay so i build this thing: https://cdn.discordapp.com/attachments/525729540434165760/538648424493481984/unknown.png
but when the explosion hits that building, nothing happens to it i want it to unachor all the part the explosion hits, but dont know how to.
I head people say something about welds but i dont know how that will help me. Thanks!
edit: fixed script
My previous solution did not work because Explosion.Hit does not detect anchored parts. Since you are trying to make anchored parts unanchored, we cannot use this. A solution then is to create a ball with the size of the explosion's BlastRadius
, then get the parts touching the ball. For all parts touching the ball, set them to be unanchored.
wait(5) local boom = script.Parent local blastradius = 10 local explosion = Instance.new("Explosion") explosion.Position = boom.Position explosion.BlastRadius = blastradius explosion.Parent = workspace local Part = Instance.new("Part") Part.Size = Vector3.new(blastradius,blastradius,blastradius) Part.CFrame= boom.CFrame Part.Shape = Enum.PartType.Ball Part.Anchored = true Part.Transparency = 1 Part.CanCollide = false Part.Parent = workspace --Generate a touchinterest. Part.Touched:Connect(function() end) local WithinExplosionRadius = Part:GetTouchingParts() Part:Destroy() for _,part in pairs(WithinExplosionRadius) do if part.Name ~= "Baseplate" then part.Anchored = false end end boom:Destroy()
Hey Rheines, thanks for helping sadly, the script you gave didn't seem to work I tried modifying it but it didn't seem to work.
i put this exact script in the exploding part
wait(3) local boom = script.Parent local explosion = Instance.new("Explosion") explosion.Position = boom.Position explosion.Parent = workspace --Connect a function to the Hit event. explosion.Hit:Connect(function(part) --Ignore baseplate. if part.Name ~= "Baseplate" then part.Anchored = false end end) boom:Destroy()
i fixed a error in which you accidentally put 2 "="s also i dont see the line of code that actually unanchors the part it touches.
Just to expand on some other variables...
-'BlastPressure' sets the amount of force applied to base parts within the 'BlastRadius'. -'BlastRadius' is the size of the explosion's radius in studs (0-100) -'DestroyJointRadiusPercent' sets the proportion of 'BlastRadius' where all joints are destoryed(0-1) If set to 0, Humanoids are not supposed to die. -'ExplosionType' is 'Craters' or 'NoCraters', determines if terrain is also damaged
wait(3) local boom = script.Parent local explosion = Instance.new("Explosion") explosion.Position = boom.Position explosion.BlastPressure = 100000 explosion.BlastRadius = 5 explosion.DestroyJointRadiusPercent = 1 explosion.ExplosionType = "NoCraters" explosion.Parent = game.Workspace explosion.Hit:Connect(function(Part, Distance) if Part.Name ~= "Baseplate" then Part.Anchored = false Part:BreakJoints() wait(.5) end end) boom:Destroy()