# What would be good to learn to do skills (kamehameha for example)

I’m going to start doing skills, I studied a bit and found key things to do that

• Cframe

• TweenService

• Debris (i didnt understand that really, anyone explain)

• BodyVelocity (dont understand too, like that part : )

``````     local velocity = Instance.new("BodyVelocity", fireBall)
velocity.Velocity = CFrame.new(fireBall.Position, mousePos).LookVector * 100
``````

Have more anything that i need learn to make good skills ? and if anyone can helpme on that points that i didnt understand

3 Likes

CFrame disguises itself as something extremely complicated, however it’s not. It has 4 values: Position, LookVector, UpVector, and RightVector.

All the Vector values would return a vector like this:

``````Vector3.new(1, 0, 0) -- LookVector
Vector3.new(0, 1, 0) -- UpVector
Vector3.new(0, 0, 1) -- RightVector
``````

However, these values create the Rotation, think of them as unit vectors. So depending on the rotation of the part, these vectors would position differently based on that.

The way you used Mouse.LookVector was actually proper, it’s just the direction it’s looking in.

Another very simple thing, it tweens parts with easing styles. Easing styles change in different ways, creating a nice smooth effect, or a constant change.

On of the most simple things in the list. It destroys objects after a certain time.

This

``````Debris:AddItem(me, 0.5)
``````

is the same as

``````delay(0.5, function() me:Destroy() end) -- same as wait, just doesn't pause code (asynchronous)
``````

Another simple thing, it’s a BodyMover, which just moves unachored parts. BodyVelocity just changes the velocity, but at a constant rate, as opposed to setting the velocity of a part, which changes based on gravity.

1 Like

why use Cfram to do that ? on the body velocity

you said cframe have 4 values Position, LookVector, UpVector, and RightVector, but you only showed 3 on the part

You already know position, it’s the positional value. Same as Part.Position.

You use LookVector because it faces in the front direction of the part. It would look wherever the mouse is facing.

I looked at it and it was actually wrong:

``````local velocity = Instance.new("BodyVelocity", fireBall)
velocity.Velocity = mouse.Hit.LookVector * 100 -- mouse.hit returns cframe
``````

So have more things that i need learn to make good skills ?

Nope. Just understanding what you listed. Maybe understanding mice (mouses) might work, It’s just an acquired skill.

Your code sample is functionally different. Neither is “wrong”. The first one is the direction from the fireball to the mouse’s position, which is definitely what he should be using for the fireball’s velocity. Your example is the direction from the camera’s position to the mouse’s position. Since it’s the camera’s position, it wouldn’t move the fireball towards where the mouse is; it would instead move it parallel to the mouse.

2 Likes

Skills and their concepts are nice, but if you don’t have a team of developers behind you it gets tedious.
If we are assuming that you don’t know anything (I’m sure you do, its just idk what you know) here are some things extra to learn if you’re alone:

1. Animations (Both how to make and especially how to manipulate)
2. Sound Effects (Where to find free ones, how to manipulate in studio)
3. Client/Server Communication (replication, remote events/functions, exploit proofing) for key presses
4. Raycasting (Some skills like laser beam make this useful for hit detection)
5. Region3/Magnitude checks (For explosions, or AOE skills)
6. ContextAction/UserInput Services (Both used for input)
7. RunService (Mainly for it’s reliability compared to “wait()” in running loops that check things)
8. coroutines (This is my highest recommendation as it can help make actions faster and simultaneous)

If you wanna know more of these, just tell me which ones you don’t know and I can help you out.

4 Likes

Coroutines, raycast and Region3/magnitude checks are hard for me, help on those

When you call a loop inside a script:

``````while true do
--crash the server lmao
end
``````

You create a thread. To be more correct, every script is it’s own thread.
A thread is simply a line of instructions the computer runs.
However you can have some problems like:

``````while true do
--crash the server
end

while true do
--save the server
end
``````

The problem here is that only the crashing server will run while the saving won’t.
To fix that we can do 2 things:

``````spawn(function()
while true do
--save the server
end)
``````

or

``````coroutine.wrap(function()
while true do
--save the server
end)() --don't forget the () because that runs the actual coroutine
``````

before the crash server loop. This causes the save loop to run at the same time that the crash server loop is ran. Therefore saving the server (lmao).
Now top notch, pro programmers on roblox that script will tell you not to use the “spawn” function because it starts after 1 “wait()” and isn’t reliable. But if you’re just beginning it shouldn’t matter.

When I have more time I’ll explain the others.

1 Like

magnitude is very easy, an example:

``````

print(head.CFrame - workspace.Part.CFrame).Magnitude) -- example of print: 123(in studs_
end)
end)
``````

Region3 is easy, with some unpack() and table knowlege is very easy

and Coroutines have various uses, like:

u can change from:

``````
local con = coroutine.wrap(function()
wait(1)
print('hi')
end)

con()

``````

to:

``````

coroutine.wrap(function()
wait(1)
print('hi')
end)()

``````

u can use coroutine.create with coroutine.resume()

a example:

``````

coroutine.resume(coroutine.create(function(
print('hi')
end))

``````

and coroutine.yield() idk why someone will use it, but an example:

``````
local IsYeldable = false

local con = coroutine.wrap(function()
if IsYeldable == false then
coroutine.yield()
else
print('Stil works')
end
end)

while wait(1) do
con()
end

wait(5)

IsYeldable = true

``````

note: coroutine.resume() works with coroutine.create() and coroutine.yield()

coroutine.status() isn’t so inportant, u can use it so u can detect if the coroutine is active or not and coroutine.running() make the same but it returns a boolean and it only works inside of coroutines. An example of coroutine.running():

``````

local con = coroutine.resume(coroutine.create(function(
while wait(1) do
print(coroutine.running()) -- print true until the next part comes
end
delay(5,function(
coroutine.yield()
end)
end))

``````

And raycast ? And thanks for help me

that is realy advanced, but i can help u, if u want to make a gun, this is the ideal code:

``````

local ray = Ray.new(script.Parent.Parent.Parent.BulletTP.CFrame.p ,(mouse.CFrame.p- script.Parent.Parent.Parent.BulletTP.CFrame.p).Unit *200) -- change 200 to ur range
local touch, position = workspace:FindPartOnRay(ray, player.Character, false, true)

``````

touch will return a object if the ray hit someting and position is the end position of the ray, it can be used to make like a bullets sistem. Hope this helped u

1 Like

if u want to use spawn() it has a minimum delay of 0.024 seconds so u should use coroutines

It matters very much because it’s not reliable and has holdovers from legacy systems. Indiscriminate use of spawn can cause various issues for you in development and it’s better to learn what they are early on so that you don’t trip yourself later, such as the fact that wait never waits the amount of time you expect and items in spawn aren’t guaranteed to run.

1 Like

Raycasting involves a direction and a position.
A direction is simply how far a point will travel:

``````Vector3.new(1,1,2)
``````

That vector direction causes a point to go 1 stud in the X direction, 1 stud in the Y direction, and 2 studs in the Z direction.

When you call:

``````player.Character.Head.CFrame.LookVector
``````

You are simply getting the direction (or slope) at which the part is looking at. It defaults to (0,0,1).

When you use it in raycasting, a proper format involves:

``````local r = Ray.new(position, direction*scale)
``````

Position is from where the ray begins and goes in the Direction as far as the scale permits. A Vector with (1,0,0) inputs has a size (or magnitude) of 1. That’s why if you want more range you multiply the direction with a scale. Or if you want a specific size of the ray you Unit the direction (make the vector the size/magnitude of 1) and then multiply it with a scale for specificity.
Uniting turns a vector like (5,2,1) down to (0.9129,0.36515,0.18257) which has a size/magnitude of 1.

So:

``````local r = Ray.new(position, direction.Unit * scale) -- .Unit units a vector
``````

Would get you a specific ray starting from Position going in Direction as far as Scale.

As @briana_superstar mentioned, Rays have multiple outputs.

``````local hit, position, normal = workspace:FindPartsOnRay(r)
``````

Are the outputs, hit being what part/object the ray touched, position being where the position touched the object, and the normal is a vector perpendicular to the surface the object touched. (See this for more info) Normals are useful for calculating ricocheting bullets or lasers.

1 Like

hi, ive seen u put at

``````

local hit, position, normal = workspace:FindPartsOnRay(r)

``````

and ‘normal’, what it means? i can’t see it on developer.roblox.com

1 Like

It’s a vector, like look vector. That points away from the object, perpendicular to the surface that was hit.