Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.