VR noclipping thru walls

,

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    body following ur head but no noclipping thru walls
  2. What is the issue? Include screenshots / videos if possible!
    i noclip thru walls
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    disabling the part of the script, i did
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    this is the client part of the script
script.Parent.Torso.CFrame = CFrame.new(script.Parent.HumanoidRootPart.Position + Vector3.new(vrservice:GetUserCFrame(Enum.UserCFrame.Head).Position.X,0,vrservice:GetUserCFrame(Enum.UserCFrame.Head).Position.Z)) * script.Parent.HumanoidRootPart.CFrame.Rotation

script.Moved:FireServer(LARM.CFrame, RARM.CFrame,script.Parent.Head.CFrame,script.Parent.Torso.CFrame, workspace.CurrentCamera.CFrame)

this is the server part of the script

local rightshoulder = script.Parent.Torso:WaitForChild("Right Shoulder")
rightshoulder.Enabled = false
local soundplayed = false
script.Parent["Right Arm"].Anchored = true
local leftshoulder = script.Parent.Torso:WaitForChild("Left Shoulder")
leftshoulder.Enabled = false
    script.Parent["Head"].Anchored = true
    script.NoCollisionConstraint.Part0 = script.Parent.Head
    script.NoCollisionConstraint.Part1 = script.Parent.HumanoidRootPart
    local neck = script.Parent.Torso:WaitForChild("Neck")
    neck.Enabled = false
    script.Parent["Torso"].Anchored = true
    local Root = script.Parent.HumanoidRootPart:WaitForChild("RootJoint")
    Root.Enabled = false
    script.Parent.Torso.CanCollide = true

To prevent noclipping, you’ll likely need to add collision detection before updating the character’s position. Try using :MoveTo() instead of directly setting the CFrame, or integrate a raycast to check for walls and obstacles in the direction you’re moving. This way, you can stop the player from moving through solid objects while still following the VR headset’s position.

2 Likes

nope, that does not work, it just makes me move to that position infinitely cuz my camera is glued to humanoid root part, and moveto moves the hum root part

I see the issue.

Since your camera is attached to the HumanoidRootPart, using MoveTo directly will keep the character moving indefinitely. Instead of MoveTo, you might want to update the position manually using a loop and interpolate the movement over time.

You can calculate the direction from the HumanoidRootPart to the target position and then use CFrame to adjust the character’s position while maintaining the correct orientation. Here’s a basic example:

local targetPosition = -- Your target position here
local speed = 10 -- Adjust speed as needed

RunService.Heartbeat:Connect(function()
    local direction = (targetPosition - character.HumanoidRootPart.Position).unit
    character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position) * CFrame.lookAt(character.HumanoidRootPart.Position, targetPosition)
    character.HumanoidRootPart.Position = character.HumanoidRootPart.Position + direction * speed * RunService.Heartbeat:Wait()
    
    if (character.HumanoidRootPart.Position - targetPosition).magnitude < 0.1 then
        -- Stop moving or perform any action needed
    end
end)

This way, you can control the character’s movement without relying on MoveTo, allowing you to smoothly transition to the target position while properly orienting the character.

1 Like

are you an artificial intellegence robot that’s designed to reply to everyone’s posts in minutes…???