Key still not working/broken?
As you can see my problem is that once the player presses the shift key he should follow the mouse and once he presses it again he should stop following the mouse and move normally after this, but it seems that if i press any key but shift it deactivates the player following mouse script again after i activate it with shift again. You can try this script yourself by putting
02 | local gyro = Instance.new( 'BodyGyro' ) |
03 | gyro.maxTorque = Vector 3. new( 1400000 , 1400000 , 1400000 ) |
05 | local cFrame = CFrame.new( 0 , 0 , 0 ) |
06 | local torso = player.Character.Torso |
08 | mouse.KeyDown:connect( function (key) |
10 | gyro.Parent = game.Lighting |
11 | if string.byte(key) = = 48 then |
18 | if string.byte(key) = = 48 then |
23 | game:GetService( "RunService" ).RenderStepped:connect( function () |
24 | local position = mouse.Hit.p |
25 | local setPosition = Vector 3. new(position.X, torso.Position.Y, position.Z) |
26 | local direction = (setPosition - torso.Position).unit |
27 | cFrame = CFrame.new(torso.Position, torso.Position + direction) |