I am trying to make a third person shooter game but cant really get perfect arm movement.
as you can see either it goes too high or too low if I am not pointing dead straight.
local Character = script.Parent
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")
local HRP = Character:WaitForChild("HumanoidRootPart")
local Head = Character:WaitForChild("Head")
local RightArm = Character:WaitForChild("Right Arm")
local Neck:Motor6D = Character:FindFirstChild("Neck",true)
local RightShoulder:Motor6D = Character:FindFirstChild("Right Shoulder",true)
local LeftShoulder:Motor6D = Character:FindFirstChild("Left Shoulder",true)
local ROff = script:WaitForChild("RightArmOff")
local LOff = script:WaitForChild("LeftArmOff")
local NeckOff = Neck.C1
local RightArmOff = RightShoulder.C1
local LeftArmOff = LeftShoulder.C1
local db = false
RunService.RenderStepped:Connect(function()
local cx,cy,cz = workspace.CurrentCamera.CFrame:ToOrientation()
local NeckCF = NeckOff*CFrame.Angles(cx,0,0)
local RArmCF = RightArmOff*CFrame.Angles(0,0,-cx-math.pi/2)*ROff.Value
local LArmCF = LeftArmOff*CFrame.Angles(0,0,cx+math.pi/2)*LOff.Value
Neck.C1 = NeckCF
RightShoulder.C1 = RArmCF
LeftShoulder.C1 = LArmCF
local LV = workspace.CurrentCamera.CFrame.LookVector
coroutine.resume(coroutine.create(function()
if not db then
db = true
wait(2)
game.ReplicatedStorage.UpdateArm:FireServer(NeckCF,RArmCF,LArmCF)
db = false
end
end))
end)
Here is my client script that handles formulas. I am dead sure its to do with my formulas as I am not a that good with maths.
Left Arm Offset:
Right Arm Offset
Thank you if you help me on this.