I was making a script that imitates the shift lock.Basically rotates the player on a angle.I was trying to do that but I got a error on the output while trying to multiply a angle with another angle so it will stay the same position.
Output:
Angles is not a valid member
Players.Player.PlayerGui.LocalScript', Line 6
Player = game.Players.LocalPlayer Character = Player.Character Mouse = Player:GetMouse() Torso = Character:WaitForChild("Torso") Mouse.Move:connect(function() Torso.CFrame = CFrame.Angles(Torso.CFrame.Angles.x,Mouse.Hit.y,Torso.CFrame.Angles.z) end)
Why did I get this error and how would I fix it?
You get this answer because Angles is a constructor and not a property of CFrame.
This means that you can create a new CFrame using CFrame.Angles() but you cannot read the Angles using it.
Try this instead:
Player = game.Players.LocalPlayer Character = Player.Character Mouse = Player:GetMouse() Torso = Character:WaitForChild("Torso") Mouse.Move:connect(function() local x,y,z = Torso.CFrame:toEulerAnglesXYZ() Torso.CFrame = CFrame.Angles(math.deg(x),Mouse.Hit.y,math.deg(z)) end)
Actually replicating the mouse lock is a lot harder though. You will need to measure the delta x,y of the mouse's movement and rotate the torso accordingly. And then you also need to somehow set the mouse back to the middle of the screen.
I might be wrong here, but I think you can instead set a property in the Player so he gets a first person camera and then manipulate properties inside the humanoid to offset the camera from the head. That would probably achieve what you are trying to do.