Way to fix viewmodel collision with character?

I’ve been experimenting with viewmodels lately, and it appears that whenever i do anything (like turning all parts no collide, moving clone parent, changing collision ids, etc) i can’t fix the viewmodel’s collision.

One that worked was that I renamed the left arm and the right arm, yet it breaks the humanoid and animation. If I try to turn off the collision myself, it turns back on.

Working way to fix this maybe?

4 Likes

Ah yes, the problem I had until I got fixed a few months ago. What I would do is getting the physics service and add collision groups.

Script in ServerScriptService:

local PhysicsService = game:GetService("PhysicsService")

pcall(function()
	PhysicsService:CreateCollisionGroup("NameOfYourViewmodel")
	PhysicsService:CollisionGroupSetCollidable("ModelName", "Default", false)
end)

In the local script, I would set the collision group to make it uncollidable.

local PhysicsService = game:GetService("PhysicsService")

local function SetCollsionGroup(Children, Group)
	for Index = 1, #Children do
		if (Children[Index]:IsA("BasePart")) then
			PhysicsService:SetPartCollisionGroup(Children[Index], Group)
		end
		SetCollsionGroup(Children[Index]:GetChildren(), Group)
	end
end
SetCollsionGroup(viewmodel:GetChildren(), "NameOfYourViewmodel") -- the viewmodel is a model 

Note:

  • The name “NameOfYourViewmodel” is a collision group. It must has the same name otherwise it won’t work.
  • The name “viewmodel” is your Viewmodel Model.
  • The name “ModelName” is the name of your viewmodel
6 Likes

SORRY FOR BUMPING THIS 4 YEARS LATER

does the collision group HAVE to be named after your viewmodel? i’d have to create a collision group for every viewmodel, can’t i just have one collision group called “viewmodel” and then change it locally?

The collision group can be named anything, it just has to be different from the ones that use your character. you could also just make it disable collisions between the viewmodel collisino group and “Default” as this works well too

1 Like