   Converting Vector to Angle (Silly question)
tool = script.Parentplayer = tool.Parent.Parentcharacter = player.Characterfunction vectorToAngle(vec)local angle = math.atan2(vec.x, vec.y)return math.deg(angle)endfunction normalizeVector(vec)local d = math.sqrt(vec.x^2 + vec.y+2)return Vec2D(vec.x/d, vec.y/d)endfunction mouseDown(pos) --where they clicked in the worldlocal torsoPos = character.Torso.Position --player character positionlocal p = create("Box")p.Name = "Rocket"p.Size = Vec2D(0.5, 1.6)p.Color = RGB(128, 128, 128)local look = Vec2D(pos.x - torsoPos.x, pos.y - torsoPos.y) --Vector between click point and player positionlocal nLook = normalizeVector(look) --Unit vectorlocal rotation = vectorToAngle(nLook) --This is the problem I thinkp.Rotation = rotationp.Position = torsoPosp.Parent = game.Worldcreate("FixedRotation").Parent = plocal v = create("ConstantVelocity")v.Velocity = Vec2D(nLook.x * 5, nLook.y * 5) --This worksv.Parent = pendtool.mouseDown:link(mouseDown)I'm trying to script a Rocket Launcher in Lua as one of the starter weapons for my own 2D sandbox building game. When the user clicks, it should make a rocket where their character is and point it towards where they clicked. Right now, projectiles move the right direction, but the rotation is off. Can anyone find the mistake in the code?   
  Assuming the atan2 equals the C variant http://cplusplus.com/reference/clibrary/cmath/atan2/ you should swap the x and y parameter for atan2. It must be atan2(y, x).   ;math.sqrt(vec.x^2 + vec.y+2)...that doesn't look right either.;Quote:Original post by Jan-Lieuwemath.sqrt(vec.x^2 + vec.y+2)...that doesn't look right either.Not all languages treat operators like "^" alike. In Lua, it seems that "^" is the Power of operator. See here.   ;Quote:Original post by nobodynewsQuote:Original post by Jan-Lieuwemath.sqrt(vec.x^2 + vec.y+2)...that doesn't look right either.Not all languages treat operators like "^" alike. In Lua, it seems that "^" is the Power of operator. See here.I think his point was that the OP isn't squaring the y component, just adding 2.   