NPC limbs with armor welds become "stiff" after a character touches them

I made an armor welding and attaching system for enlarged humanoid models. The welding is fine, but whenever my character model (or after a few minutes passes) touches the enlarged humanoid, some of its limbs become stiff.

The question is, how would I prevent the stiffness from happening?

Before stiffness

After stiffness

After a certain while, the boss is stiffed up so much that it just glides into the baseplate
RobloxStudioBeta_ydb182mfjz

Here is the code:

local function Welding(skin)
	for all, accessory in pairs(skin:GetChildren()) do
		local skinModel = accessory:FindFirstChildOfClass("Model")
		local skinHandle = accessory:FindFirstChild("Handle")
		-- weld all parts of the skin to the handle
		skinHandle.Massless = true
		skinHandle.Anchored = false
		skinHandle.CanCollide = false
		for all, skinPart in pairs(skinModel:GetChildren()) do
			local weldConstraint = Instance.new("WeldConstraint")
			weldConstraint.Part0 = skinPart
			weldConstraint.Part1 = skinHandle
			-- massless parts + cannot collide
			skinPart.Massless = true
			skinPart.Anchored = false
			skinPart.CanCollide = false
			
			weldConstraint.Parent = skinPart
		end
	end
end


local function attachSkinToCharacter(character, skin)
	for all, accessory in pairs(skin:GetChildren()) do
		local skinHandle = accessory:FindFirstChild("Handle")
		local rigidConstraint = Instance.new("RigidConstraint")
		local bodyPartName = accessory.Name
		local attachmentName = skinHandle:FindFirstChildOfClass("Attachment").Name
		local BodyPart = character:WaitForChild(bodyPartName)
		
		rigidConstraint.Attachment0 = skinHandle:FindFirstChildOfClass("Attachment")
		rigidConstraint.Attachment1 = BodyPart:WaitForChild(attachmentName)
		
		rigidConstraint.Parent = skinHandle
		accessory.Parent = character
	end
end

Welding(PreviewArmor)
attachSkinToCharacter(BossModel, PreviewArmor)

this is because the character is gaining NetworkOwnership over the accessories of the NPC, try setting the armor’s NetworkOwnership to nil (the server)

Never mind, I found a way to solve this.

Even though I disabled collisions between the player’s character model and the enlarged model, whenever the enlarged character model is touched by an unanchored BasePart and the player happens to be near the unanchored BasePart, the part gets its network ownership set to the player, and then it causes the enlarged model to act as if the player’s character did touch the model, resulting in the “stiffness” look.

The solution I proposed was to create another Physics Collision Group that enemies can collide with, and disable collision between the Default group and the Enemies group.

These are the collision variables:

-- PLAYERS AND ENEMIES SHOULD NOT COLLIDE WITH EACH OTHER!
PhysicsService:CollisionGroupSetCollidable("Players", "Enemies", false)
PhysicsService:CollisionGroupSetCollidable("Enemies", "Enemies", false)
PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)

-- Enemies can no longer collide with anything but Floors
PhysicsService:CollisionGroupSetCollidable("Enemies", "Default", false)
PhysicsService:CollisionGroupSetCollidable("Enemies", "Floors", true)

This way the only parts that enemies should touch are parts that are already anchored since all parts with the “Floor” collision group are automatically anchored, and since anchored parts are always owned by the server, there’s no unanchored parts that can collide with Enemy models, achieving my desired outcome.

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