Hello,
I’m trying to make third and first person recoil by lerping the Right and LeftShoulder C0 a bit back.
However, it doesn’t seem to work and i can’t find out why. I think the CFrame is updating but im not sure, the arm is just not moving.
Hello,
I’m trying to make third and first person recoil by lerping the Right and LeftShoulder C0 a bit back.
However, it doesn’t seem to work and i can’t find out why. I think the CFrame is updating but im not sure, the arm is just not moving.
Second, I’m presuming you’re using the old Roblox R6 characters as your references to left and right shoulder are incorrect for R15 models.
Third, this does seem to work - however the RightShould will keep moving/rotating unless you reset it.
I’ve replicated your code by guessing and this works with R6 character models.
However, the Lerp is kind of useless in this scenario unless you’re tracking the recoil and origin/desired C0 CFrames.
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = workspace:WaitForChild(player.Name)
local tool = script.Parent
local handle = tool.Handle
local FirePart = handle -- just for testing
local LeftShould:Motor6D = character.Torso["Left Shoulder"]
local RightShoulder:Motor6D = character.Torso["Right Shoulder"]
local RecoilOffset = CFrame.new(0,0,0) * CFrame.Angles(0,0,math.rad(10))
local NextFrameC0 = nil
local debounce,equipped = false,false
local ShootRemote = Instance.new("RemoteEvent",game.ReplicatedStorage) -- just for temp
local CastBehavior = 1 -- don't know what this is
tool.Equipped:Connect(function() equipped = true end)
tool.Unequipped:Connect(function() equipped = false end)
RunService.Stepped:Connect(function()
if (UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and not debounce and equipped) then
debounce = true
local mousePosition = mouse.Hit.Position
local originPos = FirePart.Position
NextFrameC0 = RightShoulder.C0
RightShoulder.C0 = RightShoulder.C0:Lerp(RightShoulder.C0 * RecoilOffset, 0.5)
print(RightShoulder.C0)
ShootRemote:FireServer(mousePosition,originPos,CastBehavior)
task.wait(0.06)
debounce = false
end
if (NextFrameC0 ~= nil) then
RightShoulder.C0 = NextFrameC0
NextFrameC0 = nil
end
end)
I will say though - it is much easier to implement Animations than messing around with C0, but if you can get it working, it will be more flexible, if less smooth.
Hi, thanks for your reply. I am aware of the code blocks, but i was in a hurry so this was easier…
I tried your code, but it doesn’t work. I may have forgotten to say that an animation with “Movement” priority is overriding it.