ShiftLock on Tools - Roblox Script Giveaway
Hey guys! Very easy to make ShiftLock on Tools. Here is the script to put in a local script under the tool: -- Disable StarterPlayer - EnableMouseLockOption local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Player = game.Players.LocalPlayer local Tool = script.Parent local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5) local CurrentState, SwimStateActive, Equipped local function ShiftLock(Active) if Active and Humanoid.CameraOffset == Vector3.new(0,0,0) then Humanoid.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset. Humanoid.AutoRotate = false -- Disable the automatic rotation since we are the ones setting it. local function ConnectShiftLock() UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter -- Set the mouse to center every frame. if HumanoidRootPart then local CameraLookVector = workspace.CurrentCamera.CFrame.LookVector HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0, math.atan2(-CameraLookVector.X, -CameraLookVector.Z), 0) -- Set the root part to the camera's rotation end end RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, ConnectShiftLock) else Humanoid.CameraOffset = Vector3.new(0,0,0) -- Move the camera back to normal. RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely. UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely Humanoid.AutoRotate = true -- Let the humanoid handle the camera rotations again. end end local function OnEquipped() Equipped = true if CurrentState == Enum.HumanoidStateType.Swimming then SwimStateActive = true else ShiftLock(true) end end Tool.Equipped:Connect(OnEquipped) local function OnUnequipped() Equipped = false ShiftLock(false) end Tool.Unequipped:Connect(OnUnequipped) Humanoid.Died:Connect(ShiftLock) -- Turn off ShiftLock When Swimming in Water local function HumanoidStateChanged(OldState, NewState) CurrentState = NewState if NewState == Enum.HumanoidStateType.Swimming and Humanoid.CameraOffset == Vector3.new(1.75,0,0) then -- Turn Off ShiftLock ShiftLock(false) SwimStateActive = true elseif SwimStateActive and Equipped then -- Turn On ShiftLock if it was Previously Active ShiftLock(true) SwimStateActive = false end end Humanoid.StateChanged:Connect(HumanoidStateChanged)
Download
0 formatsNo download links available.