Hi devs so im making a game with destruction physics and when a part is exploded i want it to stay normal for 5 seconds and then gradually make them less transparent and destroy when the transparency is 0, but is there any way i can detect if an explosion unwelded parts?, i want to do this because i dont want to add that feature a new weapon gets added
When a coin is blown up, it is no longer anchored?
without further context i’ll have to assume you’re using roblox’s default explosion.
it has an event called hit. “Note that this event will fire for every BasePart hit.”
Every time an explosion is set off, you can use the hit event to detect if it’s a destructible part and do what you will.
So, you won’t be detecting if an explosion unwelds the parts, you’ll be detecting the parts themselves on explosion and going further with your code from there.
2 Likes
okay so i did this i think it works pretty well thanks for helping me
local DebrisService = game:GetService("Debris")
local BLAST_FORCE = 1000
local function FindCharacterAncestor(subject)
if subject and subject ~= workspace then
local humanoid = subject:FindFirstChildOfClass('Humanoid')
if humanoid then
return subject, humanoid
else
return FindCharacterAncestor(subject.Parent)
end
end
return nil
end
workspace.DescendantAdded:connect(function(explosion)
if explosion.ClassName == "Explosion" then
local blastCenter = explosion.Position
explosion.Hit:connect(function(hitPart)
local character, humanoid = FindCharacterAncestor(hitPart.Parent)
if not humanoid then
if hitPart.Name ~= 'Handle' then
hitPart:BreakJoints()
local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
blastForce.Force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
DebrisService:AddItem(blastForce, 0.1)
task.spawn(function()
task.wait(10)
local tween = game:GetService("TweenService"):Create(hitPart,TweenInfo.new(3,Enum.EasingStyle.Exponential),{Transparency = 1})
tween:Play()
game.Debris:AddItem(hitPart,3)
end)
end
end
end)
end
end)
EDIT: this uses some of roblox code with mine it detects when an explosion gets added to the workspace
1 Like