So i made a Cam Script . Because i wanted a shiftlock . The prob is that now the player is able to see throught the floor and other part i dont know how to fix it so if u know help me !
Here the script :
-------------
--- INDEX ---
-------------
--Services
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local localPlayer = game:GetService("Players").LocalPlayer
local Camera = game:GetService("Workspace").CurrentCamera
local xAngle = 0
local yAngle = 0
local cameraPos = Vector3.new(1.5,1.5,15)
wait(1)
Camera.CameraType = Enum.CameraType.Scriptable
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
userInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
xAngle = xAngle-input.Delta.x*0.4
yAngle = math.clamp(yAngle-input.Delta.y*0.4,-80,80)
end
end)
runService.RenderStepped:Connect(function()
local Character = localPlayer.Character
local rootPart = Character:FindFirstChild("HumanoidRootPart")
if Character and rootPart then
local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(xAngle), 0)*CFrame.Angles(math.rad(yAngle), 0, 0)
local cameraCFrame = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,cameraPos.Z))
local cameraFocus = Character:FindFirstChild("Head").CFrame
Camera.CFrame = CFrame.new(cameraCFrame.p,cameraFocus.p)
end
end)
wait(1)
local player = game.Players.LocalPlayer
local character = player.Character
local torso = character.HumanoidRootPart
local mouse = player:GetMouse()
character.Humanoid.AutoRotate = false
mouse.Move:connect(function()
torso.CFrame = CFrame.new(torso.Position, mouse.Hit.p*Vector3.new(1,0,1) + torso.Position*Vector3.new(0, 1, 0))
end)
