In this ViewModel how could I check if “Cart” is being touched with another part?
(red circle is what is what i need to check if touched)
In this ViewModel how could I check if “Cart” is being touched with another part?
(red circle is what is what i need to check if touched)
maybe
(script within the cart)
script.Parent.Touched:Connect(function(hit)
print(hit.Name)
end)
this should tell you the name of a part that cart is touching
it wont even print out if the card is being touched, but it prints anything else that touches it
so you want to check if “cart” is being touched by the “scanner” shown in the picture?
Yes. That’s the main purpose of it.
just put the same script inside the scanner then
if you want to make it open a door for example you can do:
script.Parent.Touched:Connect(function(hit)
if hit.Name == "Cart" then
--open door
end
end)
just tried it and got nothing
does the part has CanTouch option checked?
yes it does
ssssssssssssssssss
.Touched only works for physics interaction and not for CFrame based interaction like an anchored viewmodel. Therefore it may not be the most reliable method.
I recommend using raycasting from the camera for more efficiency, or workspace:GetPartsInPart() for accuracy in a loop.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.