You can write your topic however you want, but you need to answer these questions:
I made a script that forces players into first person and changes their camera position a little forward so they wouldnt see their neck. But now if player comes close to the wall they can see through it. I tried to make a part that prevents the player to come close to the wall, but the part doesnt stop the player and goes through the wall aswell. any ideas?
local RenderStepped = game:GetService("RunService").RenderStepped
local FixModel = game:GetService("ReplicatedStorage").CamFixModel:Clone()
local FixModelRoot = FixModel.PrimaryPart
local PlayerBody = workspace:WaitForChild(game.Players.LocalPlayer.Name)
FixModel.Parent = PlayerBody
RenderStepped:Connect(function ()
FixModelRoot.CFrame = PlayerBody.PrimaryPart.CFrame * CFrame.new(0, 0, -3)
end)
local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
RunService.RenderStepped:Connect(function(step)
if char:FindFirstChild("Head") then
local ray = Ray.new(char.Head.Position, ((char.Head.CFrame + char.Head.CFrame.LookVector * 2) - char.Head.Position).Position.Unit)
local ignoreList = char:GetChildren()
local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
if hit then
char.Humanoid.CameraOffset = Vector3.new(0, 0, -(char.Head.Position - pos).magnitude)
else
char.Humanoid.CameraOffset = Vector3.new(0, 0, -1)
end
end
end)