Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop shift-lock from changing the direction the player is facing?

I have a script that works exactly as intended except for shift-lock getting in my way.

local RS = game:GetService("ReplicatedStorage")
local BlinkStrike = RS:WaitForChild("BlinkStrike")

local function onBlinkStrike(Player, MHP)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Humanoid = Player.Character:WaitForChild("Humanoid")	-- basic variables		
	local Root = Character.HumanoidRootPart

	
	local ray = Ray.new(Character.HumanoidRootPart.CFrame.p,  --casting the ray
				(MHP - Character.HumanoidRootPart.CFrame.p).unit * 50)					
	local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true)	
	
		if part and part.Parent:FindFirstChild("Humanoid") then	 --if it's a player						
			local player = game.Players:GetPlayerFromCharacter(part.Parent)
				if player then
							local target = player.Character.HumanoidRootPart
							if player.Character.Humanoid.Health > 0 and Humanoid.Health > 0 then -if both still alive...
 								Root.CFrame = target.CFrame + (target.CFrame.lookVector * (-3)) --tp behind target
								wait (0.001)	
								Root.CFrame = CFrame.new(Root.Position, target.Position)	--turn towards their back <-- here's the issue
      						end
				end	
		end
	
end

While shift-lock is on, as soon as i rotate the player it just rotates him back towards the cursor, thus if i'm aiming at the player facing me i teleport behind him facing the wrong way and i haven't found a way to fix this as i can't find a way to change the camera direction as i'd have to send data back from server to client, and manipulating shift-lock through scripts seems impossible

8 comments

0

Also, isn't it caps-lock ??

0

xD changed it, and no it's shift-lock for me at least

0

game.StarterPlayer.EnableMouseLockOption = false completely disables shift lock

0

does nothing and gives no errors

0

Cant you turn it off?

0

apparently not, i've shifted to instead changing where the player's camera is looking at but camera.Focus = CFrame.new(0,0,0) does nothing at all and it prints afterwards so i know it runs

0

well i've managed to turn it off but if it was turned on before i disabled it the camera still follows the cursor

0

you need to set the StarterPlayer property in studio otherwise it won't apply to players who have already joined, you can manually set a player's ability to shiftlock with https://developer.roblox.com/api-reference/property/Player/DevEnableMouseLock

1 answer

Apparently there is a neat workaround. Setting

Player.Character.Humanoid.AutoRotate = false

for a few seconds solves the issue

This discussion is preserved as it was. New answers, comments, and votes are closed.