I have a lock on to character script and it works fine, however when I enable shiftlock its priority is way higher than the lock on and I don’t know how to prevent that without removing shiftlock which I dont want to do.
How would I go about fixing that? I already used CFrame.lookAt and it didn’t work.
The lock on script (local):
local cas = game:GetService("ContextActionService")
local TweenService = game:GetService("TweenService")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local mouse = plr:GetMouse()
local lockedOn = false
local function getMouseOverChar()
local hit = mouse.Target
local p = Instance.new("Part")
local eChar = hit:FindFirstAncestorWhichIsA("Model")
if eChar then
local hum = eChar:FindFirstChildOfClass("Humanoid")
if hum then
return eChar
end
end
end
local function lockOn(actionName, inputState, inputObject)
if actionName == "lockOn" and inputState == Enum.UserInputState.Begin then
if lockedOn == false then
local eChar = getMouseOverChar()
print(eChar)
if eChar then
local ehrp = eChar:WaitForChild("HumanoidRootPart")
--begin lock on
print("BEGIN")
lockedOn = true
while lockedOn == true do task.wait()
TweenService:Create(hrp, TweenInfo.new(0), {
CFrame = CFrame.lookAt(hrp.Position, Vector3.new(
ehrp.Position.X,
hrp.Position.Y,
ehrp.Position.Z
))
}):Play()
end
end
else
lockedOn = false
end
end
end
cas:BindAction("lockOn", lockOn, true, Enum.KeyCode.L)