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

How can I fix an imperfection in my character-face-mouse script?

Asked by 7 years ago
Edited 7 years ago

This script works perfectly well. It's just that the arms go inside of the camera when I look up when the arms are extended in front of me. When I use my gun sights, it moves up and I'm not aiming correctly anymore. I just need some way of keeping the arms in the same offset as the camera, if that makes sense.

Here is what I don't want: http://imgur.com/a/VOfyT

Here is what I DO want: http://imgur.com/a/xqSc4

-- LOCAL SCRIPT
plr = game.Players.LocalPlayer

repeat wait() until plr.Character and plr.Character:FindFirstChild("HeadMouseFollow")

chr = plr.Character
mouse = plr:GetMouse()
game["Run Service"].RenderStepped:connect(function()
    local c = game.Workspace.CurrentCamera
    if chr:FindFirstChild("Right Arm") then
        chr["Right Arm"].LocalTransparencyModifier = 0
    end
    if chr:FindFirstChild("Left Arm") then
        chr["Left Arm"].LocalTransparencyModifier = 0
    end
    if chr:FindFirstChild("Torso") then
        chr.HeadMouseFollow:FireServer(chr, mouse.Origin.p, mouse.Hit.p)
    end
end)

-- SERVER SCRIPT
script.Parent.HeadMouseFollow.OnServerEvent:connect(function(plr, chr, origin, hitpos)
    if chr.Torso:FindFirstChild("Right Shoulder") then
        chr.Torso:WaitForChild("Right Shoulder").C0 = CFrame.new(1,0.5,0) * CFrame.Angles(-math.asin((origin - hitpos).unit.y),1.55,0)
    end
    if chr.Torso:FindFirstChild("Left Shoulder") then
        chr.Torso:WaitForChild("Left Shoulder").C0 = CFrame.new(-1,0.5,0) * CFrame.Angles(-math.asin((origin - hitpos).unit.y),-1.55,0)
    end
    if chr.Torso:FindFirstChild("Neck") then
        chr.Torso:WaitForChild("Neck").C0 = CFrame.new(0,1,0) * CFrame.Angles(-math.asin((origin - hitpos).unit.y) + 1.55,3.15,0)
    end
end)
0
maybe you should try lowering the arms a little bit? and maybe consider adjusting the camera? fanofpixels 718 — 5y

Answer this question