So I have a Bomb tool that when you click drops a bomb. 5 seconds later it explodes, and anything it touches that isn't in the "unbreakable" folder in the Workspace will be unanchored. It kinda of works. The explosion's position is the original position the bomb was dropped in. I don't know why this happens.
local debounce = true local plr = nil script.Parent.Activated:connect(function() if debounce then debounce = false plr = script.Parent script.Parent.Handle.Transparency = 1 script.Parent.top.Transparency = 1 local clone = game.ReplicatedStorage.bomb:Clone() clone.Parent = workspace.Debris clone.Position = script.Parent.Handle.Position wait(5) local explosion = Instance.new("Explosion") explosion.BlastPressure = 50000 explosion.BlastRadius = 10 explosion.DestroyJointRadiusPercent = 10 explosion.Parent = clone explosion.Position = Vector3.new(clone.Position + Vector3.new(0,2,0)) explosion.Hit:connect(function(part, distance) if part.Parent ~= workspace.unbreakable then part.Anchored = false end end) wait(1) clone:Destroy() wait(5) debounce = true script.Parent.Handle.Transparency = 0 script.Parent.top.Transparency = 0 end end)
Also, is it possible to make it so anything on top the brick that is unanchored also become unanchored?
Thanks
I don't suggest using:
if part.Parent ~= workspace.unbreakable then part.Anchored = false
As its not needed here instead use the code below and tell me if it works.
local debounce = true local plr = nil script.Parent.Activated:connect(function() if debounce then debounce = false plr = script.Parent script.Parent.Handle.Transparency = 1 script.Parent.top.Transparency = 1 local clone = game.ReplicatedStorage.bomb:Clone() clone.Parent = workspace.Debris clone.Position = script.Parent.Handle.Position wait(5) local explosion = Instance.new("Explosion") explosion.BlastPressure = 50000 explosion.BlastRadius = 10 explosion.DestroyJointRadiusPercent = 10 explosion.Parent = clone explosion.Position = Vector3.new(clone.Position + Vector3.new(0,2,0)) explosion.Hit:connect(function(part, distance) if part.Parent == workspace.unbreakable or part.Parent.Parent == workspace.unbreakable then return elseif part.Parent == workspace or part.Parent.Parent == workspace then part.Anchored = false end end) wait(1) clone:Destroy() wait(5) debounce = true script.Parent.Handle.Transparency = 0 script.Parent.top.Transparency = 0 end end)