Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How would I point this fireball where my canon surface moves?

Asked by 8 years ago

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?

local Shot = script.Parent
local cannon = Shot.Cannon
local fireball = game.ServerStorage.Fireball

while true do
local fireballcopy = fireball:Clone()
fireballcopy.Parent = game.Workspace
fireballcopy.Position = cannon.Position
fireballcopy.Velocity = Vector3.new(100,0,0)
wait(2)
end

1 answer

Log in to vote
0
Answered by 8 years ago

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))

Ad

Answer this question