Not let player come close to the wall

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. Ray stuff doesnt work because it glitches due to decorations, i cant place them all into an ignoreList… 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)

1 Like

Instead of looping the position so that the fixed hitbox will be “welded” to the player , you should instead use Welds.

why you should use welds?
Well because the part only forces itself to be to the targetted cframe without having any time to calculate any physics. Even if it would, the calculated physics will not prevent the player from not moving the camera into a wall because there is no weld or any other attachment that would handle the root part of the players character.

1 Like

oooooh thank you! it helped me!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.