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
local mode = 0 -- 0 = default, 1 = battle.
local gyro = Instance.new('BodyGyro')
gyro.maxTorque = Vector3.new(1400000,1400000,1400000)
wait()
local cFrame = CFrame.new(0, 0, 0)
local torso = player.Character.Torso
mouse.KeyDown:connect(function(key)
if mode == 0 then
gyro.Parent = game.Lighting
if string.byte(key) == 48 then
mode = 1
end
end
if mode == 1 then
gyro.Parent = torso
if string.byte(key) == 48 then
mode = 0
end
end
game:GetService("RunService").RenderStepped:connect(function()
local position = mouse.Hit.p
local setPosition = Vector3.new(position.X, torso.Position.Y, position.Z)
local direction = (setPosition - torso.Position).unit
cFrame = CFrame.new(torso.Position, torso.Position + direction)
gyro.cframe = cFrame
end)

3 comments
If your problem is fixed, please do not delete the question! You can post additional questions, so there is no value in deleting your question!
I'm very sorry i will not do this again, i'm new here so i got a lot to learn.
I still need help though as i have been trying to fix this for hours. :/