Vr Hands Won't Detect Touch Events

Hello, I am currently trying to create a grabbing system for my VR game, but whenever I try to grab specific items, such as the gun model I have for testing, it doesn’t detect its hit. It detects the player body, such as the Head or HumanoidRootPart, but not the gun model.

There is no script to show the issue, as it is a problem relying outside of it. I believe the issue is with Roblox’s touch functioning, but I am not entirely sure. The VR Hand meshes are anchored, with a handle part welded to them that is unanchored. The gun model is unanchored with cancollide off.

I think the best way to go about detection for grabbing items in VR is either going to be raycasts, or one of the workspace:GetPartsBoundInX() methods.

For instance, if the hand was already touching something, the .touched event wouldnt run, which would be quite annoying.


Anyhow if you chose not to do the methods above, the reason is probably due to how the hands work.

considering its an anchored part, Im going to bet its safe to assume that the hands are being moved via the position property and not a physics based thing.

In that case the .touched event will not run, due to how the .touched event is created. Along with that the .touched event is incredibly unreliable and I recommend using another method.

i use workspace:GetPartBoundsInRadius() for my grabbing, like Fro suggested. if you really want to use touch events, turn off cantouch on the HumanoidRootPart, Head, etc.

1 Like

Emphasizing on this, do you just check if it is within the radius of the gun handle?

1 Like

You can check if any of the parts found in workspace:GetPartsBoundInRadius() are the gun’s handle, and change the radius to however far you want to be able to grab it from

i have a “Handle” object in every item that’s around (0.05, 0.05, 0.05) in scale. then i check for any of those handles with the function.

Hey man, still got the issue?

I worked on smoething similar about a year ago, so I can’t playtest it at the moment as I don’t have my VR headset with me, but I did find a way to make a “grab” function work.

Keep in mind this was based off a Nexus framework.

On every part that I wanted to make grabbable, such as a baseball bat for example, I added this code snippet into it.

script.Parent.Touched:Connect(function(Hit)
	if script.Parent.Cooldown.Value == false then
	if Hit.Name == "Right" then
		print("Right")
		if script.Parent.EquippedBy.Value == "None" then
			script.Parent.Motor6D.Part1 = Hit
			script.Parent.EquippedBy.Value = Hit.Parent.Name
			script.Parent.Hand.Value = "R"
		end
	else
		if Hit.Name == "Left" then
			print("Left")
			if script.Parent.EquippedBy.Value == "None" then
				script.Parent.Motor6D.Part1 = Hit
				script.Parent.EquippedBy.Value = Hit.Parent.Name
				script.Parent.Hand.Value = "L"
			end
		else
			--NOTE: i think i was just super tired when i wrote this else statement
--theres no reason for this else statement lol, either that or i was going to 
--add more code, its yours to figure out!
		end
		end
	else
		return
	end
end)

Thanks, you were all very helpful. The issue with the part detection has now been solved, and I should be able to figure out the other grab mechanics (such as connecting the gun to the hand). :+1:

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