Hello, I am making a weapon system, when the player equips his gun, I want the body of his character to look where the camera looks, I have two scripts, a server script and a local script… The only problem is when the character looks up or down, he looks sidewsays. I know why this is happening, it is happening because the root of my character is rotated in my gun animation, I rotated its root because I wanted it to look realistic. But I don’t know how to fix it…
I can’t upload a video because it keeps saying “Sorry, there was an error uploading that file. Please try again.”…
Server script :
local waist = script.Parent:WaitForChild("UpperTorso"):WaitForChild("Waist")
local ev = script.Parent.Cam
local chr = script.Parent
function answears(plr,newLook)
if script.Parent.ShiftLock.Value == true then
local x,y,z = newLook:ToEulerAngles()
waist.C0 = waist.C0:lerp(CFrame.new(waist.C0.p) * newLook, 0.1)
else
waist.C0 = CFrame.new(0,0,0)
end
end
ev.OnServerEvent:Connect(answears)
Local script :
local chr = script.Parent
local waist = chr:WaitForChild("UpperTorso"):WaitForChild("Waist")
local ev = chr:WaitForChild("Cam")
function fire()
if script.Parent.ShiftLock.Value == true then
local look, origin = game.Workspace.CurrentCamera.CFrame, chr.HumanoidRootPart.CFrame
look = look:ToWorldSpace(CFrame.new(0, 1.5, 0))
local x,y,z = look:ToEulerAnglesXYZ()
local rx,ry,rz = origin:ToEulerAnglesXYZ()
x = math.clamp(x, -72, 72)
local newLook = CFrame.Angles(x,y,z)
local newOrig = CFrame.Angles(rx,ry,rz)
newLook = newOrig:ToObjectSpace(newLook)
ev:FireServer(newLook)
waist.C0 = waist.C0:lerp(CFrame.new(waist.C0.p) * newLook, 0.1)
else
waist.C0 = CFrame.new(0,0,0)
end
end
game:GetService'RunService'.RenderStepped:connect(fire)
Thanks!