#custom Shiftlock
1 messages · Page 1 of 1 (latest)
local Input:UserInputService = game:GetService("UserInputService")
local RunService:RunService = game:GetService("RunService")
local TS:TweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local rootpart = character.HumanoidRootPart
local indice = true
local TI = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
Input.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
if indice == true then
indice = false
humanoid.AutoRotate = false
Input.MouseDeltaSensitivity = 0.65
Input.MouseBehavior = Enum.MouseBehavior.LockCenter
local tween = TS:Create(humanoid, TI, {CameraOffset = Vector3.new(3, 0, 0)})
tween:Play()
RunService:BindToRenderStep("CamLock", 0, function()
task.wait()
local LV = workspace.CurrentCamera.CFrame.LookVector
local flatLV = Vector3.new(LV.X, 0, LV.Z).Unit
local GoalOrientation = CFrame.new(rootpart.Position, rootpart.Position + flatLV)
rootpart.CFrame = rootpart.CFrame:Lerp(GoalOrientation, 0.4)
end)
else
indice = true
humanoid.AutoRotate = true
Input.MouseDeltaSensitivity = 1
Input.MouseBehavior = Enum.MouseBehavior.Default
local tween = TS:Create(humanoid, TI, {CameraOffset = Vector3.new(0, 0, 0)})
tween:Play()
RunService:UnbindFromRenderStep("CamLock")
end
end
end)
if i move slow it's not as noticeable, but if i move the camera too fast you can see the character jitter a little
picture version if it's easier for you to read
roblox already has a shiftlock
i'm trying to make my own
so that it work when i press control instead
you can modify the key that trigger the lock
local Input:UserInputService = game:GetService("UserInputService")
local RunService:RunService = game:GetService("RunService")
local TS:TweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local rootpart = character.HumanoidRootPart
RunService:BindToRenderStep("CamLock", 0, function()
task.wait()
local LV = workspace.CurrentCamera.CFrame.LookVector
local flatLV = Vector3.new(LV.X, 0, LV.Z).Unit
local GoalOrientation = CFrame.new(rootpart.Position, rootpart.Position + flatLV)
rootpart.CFrame = rootpart.CFrame:Lerp(GoalOrientation, 0.4)
end)
relevant variables on top and the code that does the custom shiftlock below
what happens when you lower the time for the tween
it would be too slow for my liking and still continues to jitter noticeably
ideally i'd like it to be almost instant but it would jitter way too much
so i gave up that idea and try to keep it somewhat fast
i lerp it on RenderStep already, and yes it's a client script
i lerp the CFrame, but the Position doesn't change between starting and goal value
so it just lerp the orientation
have u tried lerping the character using PivotTo()
doesn't this just move the character ?
no, it sets the cframe
i'll try it
in fairness i havent read the code cos im on mobile so give me a couple mins and then i can acrually read it 😭
if you just modify the rotation you need euler angles
CFrame use 2 coordinates
and i get the orientation with a coordinate
hm i could still try using only rotation tho
since the camera have an orientation property
yeahh i'll try it now
its only y axis
WITH A KALASHNIKOV!!!!!!
bro is triggered by the guy with the kalashnikov bro, only csgo players get this mad
it didn't work
it didn't work at all in fact, my character started flying
i only modified the rotation
okay nevermind i got it to work that way
thank you
local Control = script.Parent:WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController")
Control:WaitForChild("BoundKeys").Value = "LeftControl"