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

[SOLVED] Why does my aiming system CFrame not go back to its orignal place?

Asked by 3 years ago
Edited 3 years ago

So the problem is that my aiming system is not working like it's supposed to. If I press mouse2, I will aim, but when I put my mouse up, it decides not to go out of the aiming and just stay in the aiming position.

Aim part of the script (local):

mouse.Button2Down:Connect(function()
    if currentWeaponType ~= "Melee" then
        aiming = true
    end
end)

mouse.Button2Up:Connect(function()
    aiming = false
end)


runService.RenderStepped:Connect(function()
    if aiming == true and currentWeaponType ~= "Melee" then
        aimCFrame = aimCFrame:Lerp(CFrame.new(weapon:GetAttribute("AimCFrame")), .25)
        camera.FieldOfView = weapon:GetAttribute("AimFOV")
    elseif aiming == false then
        aiming = aimCFrame:Lerp(CFrame.new(0,0,0), .25)
        camera.FieldOfView = 70
    end

    weapon:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0,-1,0) * aimCFrame)
end)

When putting a print in the button2up event it will print, but the arm will not go back to its original position.

Thanks for reading!

0
Instead of trying the get the attribute, try setting it manually or maybe there is something attribute. RichDiggerW189 2 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I fixed it. I accidentally put the aiming variable instead of aimCFrame on line 17. Wasn't worth the entire hour I tried to fix this very simple mistake.

Ad

Answer this question