So, I’m making a shooter and I’ve found a force Shift Lock Script and I’ve found an issue:
I can peek through walls. I have no idea how to fix this.
code:
-- // Variables
-- # Services
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local playersService = game:GetService("Players")
local TweenService = game:GetService("TweenService")
-- # Objects
local player = playersService.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character.HumanoidRootPart
local humanoid = character.Humanoid
local camera = game.Workspace.CurrentCamera
-- // Functions
humanoid.CameraOffset = Vector3.new(3, 1, 0)
humanoid.AutoRotate = false
runService:BindToRenderStep("Shiftlock", Enum.RenderPriority.Character.Value, function()
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative
local cameraCFrame = camera.CFrame
local lookVector = -cameraCFrame.LookVector
local angle = math.atan2(lookVector.x, lookVector.z)
--TweenService:Create()
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * CFrame.Angles(0, angle, 0)
end)