How to make a "destroying" animation

So, I was trying to do a “destroying animation” without an animation, just using Vectors and other things, but I can’t
Here the video of what im trying to do:

Any help welcome

10 Likes

What is the goal? You want a script to run when a part is destroyed? Need more details

2 Likes

Imagine a part with a click detector, everytime you click it, it do the animation

1 Like

Okay, put a ClickDetector and a script in the part and write this:

script.Parent.ClickDetector.MouseDown:Connect(function ()
   -- animation
end)
2 Likes

Yeah, I know that, but what I’m trying to do is the animation

2 Likes
game.TweenService:Create()
3 Likes

try using particles maybe to create the debris from the thing youre trying to destroy

if you want you can check out this resource that lets you create 3d particles

4 Likes

Let’s break down the process - Abstraction we call it:

Upon being hit, the object:

  • Shakes a lil bit, rotating on its own axis but notice, not moving or scaling
  • Emits a lil particles

The “Shaking” can be done with CFrames. Just notice, if the object you are trying to do the CFrame manipulation with is a “model”, ensure everything is welded together and you are only moving the Frame of the primary part.

Requirements for this would be:

TweenService
math.sin(), math.cos() --All those good trigonometric functions

Why I say Trigonometric functions is that it continues to rotate. And you can make it shake for less than a second, whatever suits you.

Particle effects you could yoink from somewhere else, idk, maybe a free model.

Just a note, what was the ultimate issue with using Vectors? You were on the right track, just use CFrames as it is easier but other than that, could you clarify what was your issue with using Vectors? There is no real point of creating a Roblox “Animation” object for this mind you, too much work for what is worth.

2 Likes

This is really cool, thank you for showing me this .

Particle effects you could yoink from somewhere else, idk, maybe a free model.

Use the 3D particle API he mentioned as it is actually nice.

3 Likes

Message me for if you just flat out want the script, it is late for me now but I can write it out tomorrow - just know if you use my comment as an insight, you learn more than just copying code.

1 Like

I tried to use what you told me, but I can’t.

1 Like

What is the exact issue yo, why “can’t” you do it? Are you struggling to do it or is something not happening? Send a clip of your exact script and the result it is outputting

1 Like

I don’ know how to use math.sin and math.cos

1 Like

Tomorrow, I shall teach you. Wait up.

2 Likes

Alright. Let this little abomination represent our rock.


image
In the workspace it is simply is the “Model” object

Add a “Click Detector” to your model, so that the whole model can be clicked on if you hover your mouse on it. This is how my model looks by the way, just random parts slapped together to make a somewhat rock looking shape.
image
Focus on the part named rock, we will go to that later

On each of the parts under “Model”, other than the one named “Rock”, we want to apply a WeldConstraint instance.
image
Like follows.
In each WeldConstraint, make the Part0 property to be the parent part that it is on and the Part1 property to be the “Rock” part. I like to think of it as Part0 being the object we want to be the source of transformations applied and Part1 being the transformations of the object we want to copy, however the order does not matter

We are doing this so, when we do the rotations on the “Rock” part, the other parts copy the rotations across their respective positions to maintain proportions.
In our “Model”, set the PrimaryPart property to “Rock”

For the WeldConstraint to work properly, ensure all the parts under Model, OTHER THAN “Rock” are Unanchored so rock IS the only anchored one.

Let’s add a (Server) Script then.
image

Here is the script for the code, mostly explained.
Remember, the axis is represented by this in studio
image

local TweenService = game:GetService("TweenService") -- If we do rotations without this, it will not be smooth, it will be as if the object "teleported" into its rotations

local rockModel = script.Parent -- Remember, our script is Parented to our "Model"
local rockModelPrimaryPart = rockModel.PrimaryPart
local clickDetector = rockModel.ClickDetector

local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Elastic, Enum.EasingDirection.In, 0, true) -- the last argument "true", is important so that it returns to its original position
local debounce = false -- Ensuring it rotates only if it stopped doing its rotating "animation"

clickDetector.MouseClick:Connect(function(playerWhoClicked)
	if debounce then return end -- So if you do not know, if you make your function return something before it even completes the code block, the function already ends
	
	debounce = true
	local goal = {}
	goal.CFrame = rockModelPrimaryPart.CFrame * CFrame.Angles(0.1, 0, 0) -- Rotating it across the X-axis
	
	local rockBreakTween = TweenService:Create(rockModelPrimaryPart, tweenInfo, goal)
	rockBreakTween:Play()
	
	rockBreakTween.Completed:Connect(function() debounce = false end)
end)

What you should be seeing:
robloxapp-20231223-1022441.wmv (528.8 KB)

2 Likes

Add the particles yourself, this part is what I assume you were struggling with and wanted to do the most

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.