'ROBLOX: How to create viewmodel bobbing/movement?

What's my problem?: I've been trying to look through scripts, looking on DevForum, and/or YouTube for anything. Nothing so far :*(

Elaborate: I have my Viewmodel set up (Viewmodel is a first person arm model that only the player can see.) and I know how to animate it. I am just puzzled on cosine bobbing for the model, I can't figure out how to do it. And for the regular movement, I want to know how to detect which way the camera is moving, and then move the model in that direction. Its just a minor detail I've wanted to master.

What I need/want: Sources that are good examples, or somebody to tell me how to do it. I just want an explanation of how to do the math, and how to move it. I can provide my current script if you like.

Anything helps :)

I've tried copy and pasting script lines into mine, cause I thought maybe it'd work, and I expected it to do exactly what it did to the other models.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source