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

?Help on making recoil w tweens and CFrames

Asked by 3 years ago

First post here, so not exactly sure how its gonna go but as the title says, im trying to make scripted recoil using the TweenService and CFrames. I’ve read through multiple threads and topics and came up with this (semi functioning) code.

function recoil()

    local cfV = Instance.new("CFrameValue")
    local tweenInfo = TweenInfo.new(
        1,
        Enum.EasingStyle.Quad,
        Enum.EasingDirection.Out,
        0.1,
        false,
        0.1)
    local bounce = {
        Value = CFrame.new(0, 0, 0)
    }
    local rec = tweenService:Create(cfV,tweenInfo,bounce)
    rec:Play()
    local conn = runService.RenderStepped:Connect(function()
        cam.CFrame = cam.CFrame * CFrame.Angles(0.1,math.rad(0),0)
    end) 
    rec.Completed:Connect(function()
        if conn then
            conn:Disconnect()
        end
    end)
end

What its SUPPOSED to do, is tween the camera up, and then disconnect itself using the rec.Completed function. However what it instead does is just continue tweening up and up, despite the disconnect function.

Ontop of that, im not even sure at how im supposed to script the camera to return to its previous position after the function is done, (how am I supposed to make recoil recovery). Help is much appreciated…

1 answer

Log in to vote
0
Answered by 3 years ago

Value = CFrame.new(0, 0, 0) to CFrame = CFrame.new(0, 0, 0)

0
i dont understand how that fixes anything Pancaken8 3 — 3y
0
just copy me lehoaiquoc248 23 — 3y
Ad

Answer this question