I have a fireball script that spawns on the canon and shoots on the XAxis, but I realized that if my part moves, it continues to point at the X axis? Now I've decided I want it to leave the brick from the BackSurface so it will leave off of the same end of the brick. But I'm an amateur scripter. Help please?
01 | local Shot = script.Parent |
02 | local cannon = Shot.Cannon |
03 | local fireball = game.ServerStorage.Fireball |
04 |
05 | while true do |
06 | local fireballcopy = fireball:Clone() |
07 | fireballcopy.Parent = game.Workspace |
08 | fireballcopy.Position = cannon.Position |
09 | fireballcopy.Velocity = Vector 3. new( 100 , 0 , 0 ) |
10 | wait( 2 ) |
11 | end |
You can manipulate directions using CFrames. Some options:
Rotate the lookvector 180 degrees:
fireballcopy.Velocity = (cannon.CFrame * CFrame.Angles(0, math.pi, 0)).lookVector * 100
Convert "backwards" ( Vector3.new(0, 0, 100) ) from local coordinates (ie what the cannon thinks is backwards) to World Space (ie the "real" direction):
fireballcopy.Velocity = cannon.CFrame:vectorToWorldSpace(Vector3.new(0, 0, 100))