So i made a thing, where the character’s UpperTorso looks where the camera looks. Fine and dandy but when it leans foward the torso snaps to a weird orientation.
See, the thing is, i don’t even know where to start with this. What went wrong? But at least i isolated it.
local waist = script.Parent:WaitForChild("UpperTorso"):WaitForChild("Waist")
local ans = script.Parent.CamAns
function answears(plr,look,origin)
waist.C0 = CFrame.new(waist.C0.p, (Vector3.new((look.X - origin.X) / 10,(look.Y - origin.Y + .75) / 10,(look.Z - origin.Z) / 10)))
end
ans.OnServerEvent:Connect(answears)
FINALLY… PEOPLE @SnarlyZoo The event requests the camera LookVector already. @luaVovert I will try that but… don’t quite understand the content of the script.
As for the actual problem, maybe try applying a limit to the X rotation, so it doesn’t go too far forward. You may be giving the engine numbers it doesn’t quite understand, and it’s snapping the waist to an unexpected position, for lack of a better way of wording it.
Okay but what about when he turns back with his whole body?
His body doesn’t turn all the way down. That is the reason why i thought the calculations the code does with the CFrames is wrong.
Ight.
So… we run the RequestCam that sends a request to the client to share where the camera is looking (LookVector). Then the LocCam sends it (roblox doesn’t allow this kind of data to be known by the server (or any other player data) by default so we have to get it somehow).
(btw we get where the HumanoidRootPart is facing too because while testing it lagged behind if we were to mesure from the BodyRotate)
BodyRotate is the brain of it.
We take the Motor6D that connects the UpperTorso and LowerTorso. function answears(plr,look,origin) this is where you got stuck i think.
plr: player… obv
look: camera LookVector
origin: HumanoidRootPartLookVector (so the script knows just from where it should rotate it from)
We set the WaistCFrame by doing this: (look.X - origin.X) / 10 the /10 is to not over rotate.
You are not dumb it’s just a mess. And i thank everyone who helps.