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…
Value = CFrame.new(0, 0, 0) to CFrame = CFrame.new(0, 0, 0)