Using TweenService to create an explosion like effect

Greetings, in my game you can mine things. When you click to mine an object all the parts in it individually shake and it looks really cool. For when players destroy objects, how would I make an explosion effect where all the different parts would just fall down (through the floor or terrain) in different directions?

2 Likes
  • For the explosion effect, you can simply use explosion object, set its position to the destroyed mineral, and make it explode after the object is mined. And if you want play with some of its properties.

  • To make the parts fall down through the floor, simple set the Cancollide property of all the parts to false, then they will all fall

  • And for making the parts go randomly in different directions, as long as the explosion is perfectly in the center of everything, and all the parts are unanchored, they should go flying as you can see in this gif
    3R4XqqUn43

1 Like

My bad for not explaining this properly, but I meant not a real explosion object. Just a function that uses tween service to make parts fall through the floor in random directions with not too much velocity.

2 Likes

I made something somewhat similar a while ago, It’s not the best code, however hopefully it can guide you towards the right direction.

local tool = script.Parent.Parent
local tween = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local db = false
tool.Activated:Connect(function()

    local goal = {Size = Vector3.new(50, 50, 50), Transparency = 1}    

    if db == false then
        
        local newPart = Instance.new("Part")
    newPart.Parent = workspace
    newPart.Anchored = true
    newPart.Transparency = 0.5
    newPart.BrickColor = BrickColor.new("Institutional white")
    newPart.Shape = Enum.PartType.Ball
    local Tween = tween:Create(newPart, tweenInfo, goal)
        db = true    
    
    Tween:Play()

wait(4.3)
db = false

    end
end)

https://gyazo.com/a0bda4464f6e64d75c224ab9f56cb5a9

5 Likes

Again, sorry. I said individual parts (not just one brick that looks like an explosion) of a model that don’t really explode, they just fall apart like if a small weak explosion hit all the parts.

Instead of using tween service, is it possible to set the velocity to a random amount relative to the angle at which the explosion touches the part while also setting its can-collide to false? Similar to how the old paintball gun uses velocity, though not containing any rotational values directly, it still manages to launch a paintball into a certain direction by using various math functions. I think that honestly the best solution is to set the part that the explosion touches to unanchored, give it a random velocity that is directional, and then re anchor the part as well as setting can collide to true after some time if necessary. I do recommend a storage for explode-able parts to be made so that certain things like the base plate wont be destroyed.

2 Likes

Whoops, forgot to resolve this topic! I ended up using bodymovers to move some CanCollide = false parts.

5 Likes