Hello! My issue today: My gun doesn't look downwards when I do, but instead it just faces forward, even when I look downwards.
Here's my code:
1 | script.Parent.Equipped:Connect( function () |
2 | module:OnEquip(player) |
3 | while true do |
4 | if player.Character:FindFirstChild( "NewHead" ) then |
5 | script.Parent.Union.Orientation.Y = player.Character.Head.Orientation.Y |
6 | end |
7 | wait( 0.1 ) |
8 | end |
9 | end ) |
My characters' heads rotate with the camera. This is in a ServerScript in the gun.
Thanks, MaximussDev.
Found the answer!
You need to adjust the player's UpperTorso CFrame using this code:
01 | wait( 0.25 ) |
02 |
03 | local c 0 = game.Players.LocalPlayer.Character:WaitForChild( "UpperTorso" ):WaitForChild( "Waist" ).C 0 |
04 |
05 | function updatewaist() |
06 | local cameralookvectorY = workspace.CurrentCamera.CFrame.lookVector.Y |
07 | local radian = math.asin(cameralookvectorY) |
08 | game.Players.LocalPlayer.Character.UpperTorso.Waist.C 0 = c 0 *CFrame.fromEulerAnglesYXZ(radian, 0 , 0 ) |
09 | end |
10 |
11 | while wait( 1 / 50 ) do |
12 | updatewaist() |
13 | end |
Keep in mind, this is just what I did. You can change your 'while wait()' speed to whatever.