Hey guys, i’m currently making a leaning system and i’m try to get my fps arms to also rotate with the camera, here’s a video on what it looks like:
As you can see, it works but the arms don’t follow. Here’s my code for it so far:
Tool.Equipped:Connect(function()
game.Players.LocalPlayer:GetMouse().Icon = "rbxassetid://117431027"
Gui = Player.PlayerGui:WaitForChild("Gun")
ToolEquipped = true
Arms = game.ReplicatedStorage.Arms:Clone()
Arms.Left.Transparency = 0
Arms.Right.Transparency = 0
Arms.Parent = game.Workspace
ParticleEmitter = Arms.BulletEffect.ParticleEmitter
GunName.Text = Tool.Name
AmmoCount.Text = (Bullets .." / ".. Ammo)
Gui.Enabled = true
--Animation1
ThirdPersonIdle()
local AnimationIdle = Arms.Animations.Idle
local AnimationController = Arms.AnimationController
TrackIdle = AnimationController:LoadAnimation(AnimationIdle)
TrackIdle:Play()
local Connection = RunService.RenderStepped:Connect(function()
cameraCFrame = workspace.CurrentCamera.CFrame
Arms.MainThing.CFrame = (cameraCFrame * CFrame.new(0,-2,-1.5) * CFrame.Angles(0,-45,0))
end)
--When uneqipping a tool
Tool.Unequipped:Wait()
Connection:Disconnect()
Arms:Destroy()
Gui.Enabled = false
Reload = false
ToolEquipped = false
ThirdPersonTrackIdle:Stop()
end)
To attempt to glue the rotation, i’ve tried to do this:
local x, y, z = game.Workspace.CurrentCamera.CFrame:ToEulerAnglesXYZ()
Arms.MainThing.CFrame = (cameraCFrame * CFrame.new(0,-2,-1.5) * CFrame.Angles(0,-45 + z,0))
However, this is to no avail, can anyone please help me on this issue? Thanks in advance!