Shiftlock when player equips tool

  1. What do you want to achieve?
    I would like to have the player shiftlock when they equip a tool

  2. What is the issue?
    I have no idea if this is even possible

  3. What solutions have you tried so far?
    I have tried to make it so when the player presses the key to target lock a player they will also shiftlock but it just makes the target lock system not work.

Code of the target lock system just incase
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local c = Player.Character

local mouse = Player:GetMouse()

local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")

local Target = nil
local CamBlock = Instance.new("Part", workspace.CurrentCamera)
CamBlock.Size = Vector3.new(1,1,1)
CamBlock.Transparency = 1
CamBlock.CanCollide = false
local BP = Instance.new("BodyPosition", CamBlock)
BP.maxForce = Vector3.new(math.huge,math.huge,math.huge)
BP.D = 500

UIS.InputBegan:connect(function(input,typing)
	if typing then return end
	if input.KeyCode == Enum.KeyCode.Q then
		if mouse.Target and mouse.Target.Parent:findFirstChild("Humanoid") then
			Target = mouse.Target.Parent
			CamBlock.Position = CFrame.new(c.HumanoidRootPart.Position, Target.PrimaryPart.Position)*CFrame.new(0,4,9).Position
			BP.Position = CFrame.new(c.HumanoidRootPart.Position, Target.PrimaryPart.Position)*CFrame.new(0,4,9).Position
		else
			Target = nil
		end
	end
end)

RS.RenderStepped:connect(function()
	if Target and (c.HumanoidRootPart.Position-Target.PrimaryPart.Position).magnitude < 80 and Target.Humanoid ~= nil and Target.Humanoid.Health > 0 and c.Humanoid ~= nil and c.Humanoid.Health > 0 then 
		local CamPos = CFrame.new(c.HumanoidRootPart.Position, Target.PrimaryPart.Position)*CFrame.new(0,4,9).Position
		BP.Position = CamPos
		workspace.CurrentCamera.CameraType = "Scriptable"
		workspace.CurrentCamera.CFrame = CFrame.new(CamBlock.Position,Target.PrimaryPart.Position)
		local Dist = (c.HumanoidRootPart.Position-Target.PrimaryPart.Position).magnitude
	else
		Target = nil
		workspace.CurrentCamera.CameraType = "Custom"
	end
end)

*not asking for an entire system done out for me, just how it can be done

1 Like

Hi, Making the player shiftlock is infact possible, I was looking around and this community-resources post explains in detail how to do just this.

Link to post.

I hope this helps