Roblox VFX and power abilities

  • Hello, I would like for some input on what to do in order to make roblox VFXs and abilities as I have no knowledge regarding those. Example, making a ‘rock-rising-from-the-ground-when-key-is-press’ is something I want to make.

  • I know how to make the animations, User Input S, and all but what I don’t know is how you get the rocks to burst out of the ground. I’ve been searching on youtube but all I get is some code 600 lines long and ask me to copy and paste. None of the tutorials actually explain what’s happening or how it works. So I would like a little explanation on how those rocks come out and how I can achieve it.

Thank you

2 Likes

Make a new part underground and cframe it upwards

This can be broken down into a few nice and simple steps that may take some time to work out but once you do you’ll have a pretty good understanding of the topic.

Let’s say, as you’ve put it, you’ve gotten the command to the server that the player wants to kick a rock 50 studs in front of them. There are multiple ways to do this, so let’s go through them 1 by 1.

Firstly, through whatever player data access you have, you’ll have to make a debounce. If this is already active, don’t kick the rock as it’s on cooldown, but if not then turn on the debounce and we can continue. You can turn this off later.

Next, I assume you’ll be cloning the model for the rock from some sort of storage, so lets say you’re taking it from ReplicatedStorage. The line should look something like this:

local model = game:GetService("ReplicatedStorage") -- Finish the path to the rock model here

Now, you have the model, you’ve put it into workspace, etc. However, we now have a problem. Where do we put the part? Let’s use this lovely drawing I made as an example.
image
As you can see, we have the players torso position and we want the rock to be 3 studs in front and 3 studs down of the player. Now, to put it in front, we can’t just use one axis, as if we use the z axis it’ll work for one side but not the other, and that’ll just be inconvenient. So, instead, we’ll use the LookVector. The name is pretty self explanatory, and it basically just returns a vector which is where the part is facing. It is also equal to 1 stud (may mean it’s normalized but feel free to tell me otherwise if so), meaning we can just do the LookVector * 3 as that’ll give us 3 studs in the direction. Now, to get it facing down, luckily the down direction will always be -3, as unless you’ve got upside down gravity, we’ll always be going down by that set amount.

With some rough work, it should look like this, however it’s pretty messy and can probably get cleaned up and simplified.

model.Position = model.Position + (torso.CFrame.LookVector * 3) + Vector3.new(0,-3, 0) -- You can also do +=

Here comes the part however where you get more freedom. To make the model move, you’ll have to use some sort of force or make your own. Roblox supplies us with 2 premade velocities, that being Vector Forces and Body Velocities. I strongly recommend using Vector Forces and BodyVelocities are legacy, however this tutorial/ post will be using Body Velocities as I’m just better at using them.

Now, let’s get started with this. Let’s say you’ve created the body Velocity, parented it to the model, given it a set maxForce etc. What we really care about is the Velocity it’s moving at, and where it’s going. Let’s use this sample code from below to help us out.

local bodyVel = Instance.new("BodyVelocity") 
bodyVel.Parent = model
bodyVel.MaxForce = Vector3.new(5000, 5000, 5000) 
bodyVel.Velocity = -- ???

As you want the Velocity to be, 20 studs per second from the front of the players torso, we’ll need to return to the players LookVector. As we know, this is the direction they’re facing. Velocity in BodyVelocities in measured in studs per seconds, and since we know the LookVector is always in 1 stud units, we can just redo the LookVector * 20, which will look like such:

bodyVel.Velocity = torso.CFrame.LookVector * 20

After a set amount of time, you can simply clean up the part, set the debounce to false, do whatever vfx you’d like and you’ll be on your merry way.

Hoped this helped!

4 Likes