So, I am making a fireball script when a player press F and it works except for the rotation of the fireball, i want the rotation to be facing the same way the player is facing and I don't know what I did wrong here.
Script:
01 | local plr = game.Players.LocalPlayer |
02 | local mouse = plr:GetMouse() |
03 | CanShoot = true |
04 | In = false |
05 |
06 | repeat wait() until plr.Character |
07 | local char = plr.Character |
08 |
09 | mouse.KeyDown:connect( function (key) |
10 | if key = = "f" then |
11 | if CanShoot = = true and In = = false then |
12 | In = true |
13 | CanShoot = false |
14 | local part = Instance.new( "Part" ) |
15 | local fire = Instance.new( "Fire" ,part) |
The Problem Is At Line 26 And I Don't Know What I Did Wrong Here.
Remove Line 26 and replace it with this. [MAKE SURE THE PART IS NOT ANCHORED!]
1 | local move = Instance.new( "BodyVelocity" , part) |
2 | move.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
3 | move.Velocity = plr.Character.Torso.CFrame.lookVector* 100 |
Brief explaination;
We will create an object called BodyVelocity. Then we will change the MaxForce (or max power) and changing the Velocity to face the character's direction, defined as plr.Character.Torso.CFrame.lookVector
. lookVector is the property of CFrame, AND NO OTHER ELSE!! lookVector just means where an object is looking or where the surface called FrontSurface of a part is facing. You can change the 100
to something else since it tells how fast it is going, and 100 is kinda fast. Hope this helps!