I'm starting to get into frameworking, and I've made a few first person weapon animations using the roblox animation editor. They're pretty basic, but I want to test them out. Only problem is my framework script that keeps the gun model in view in the camera at all times isn't work properly.
Script:
local rs = game.ReplicatedStorage
local run = game:GetService("RunService").RenderStepped
local cam = game.Workspace.CurrentCamera
local gun = rs.ak
gun.Parent = cam
delay(0,function()
while run:wait() do
gun.Body.CFrame = gun.Body.CFrame:lerp(cam.CoordinateFrame * CFrame.new(2,-1,-2), 0.5)
end
end)
It's a pretty basic script, it just takes the gun model (ak) and puts it into current camera, and makes it so that it's in view at all times (so no matter where you look, the gun is in view). The problem is that the view of the gun that you see in camera is backwards, so instead of seeing the gun, you can only see the back of the viewmodels arms. Now, I could take the easy way out and just animate all my guns facing a certain direction so that they show up correctly in view, but I want to figure out the coding solution to this. So how would I rotate the model so that it appears facing the correct direction in the camera view? Like I said, the view is completely backwards, so I would need to change it by 180 degrees each render step, I just have no idea how to do that (I think it involves angles, which is something I've never touched before).
All help is appreciated!
