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

Camera in viewmodel animation not going as intended. How do I fix it?

Asked by 3 years ago
Edited 3 years ago

The Camera in my animation:

https://gyazo.com/633d69bbd806399d238180f231344b96

The camera when i play the animation:

https://gyazo.com/0d5f83348a066de96dcc13be7ca4746f

Heres my script:

local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local runservice = game:GetService("RunService")
local gunTool;
print("SHEEEEEESH-------------------------")
local function setcam(viewmodel)
    while guntool and viewmodel and runservice.RenderStepped:Wait() do

        viewmodel:SetPrimaryPartCFrame(cam.CFrame*CFrame.new(-0.9, -1, -1)) --How do I put it the CFrame of the camera in the first video my animation here?
    end
end

character.ChildAdded:Connect(function(child)

    if child:IsA("Tool") and child.Name == "FastCastGun" then
        guntool = child
        local viewmodel = game.ReplicatedStorage.fpsak47:Clone()
        viewmodel.Parent = cam
        setcam(viewmodel)

    end

end)

character.ChildRemoved:Connect(function(child)
    if child and child == guntool then
        guntool = nil
        local viewmodel = game.ReplicatedStorage.fpsak47:Clone()
        viewmodel.Parent = cam
        if viewmodel then

            cam:ClearAllChildren()
        end
    end
end)
0
Isnt the cam cframe just workspace.currentCamera.CFrame? AlexanderYar 788 — 3y
0
no my cam in cam.CFrame is a variable RichDiggerW189 2 — 3y

Answer this question