Squashed Body With Muscle Script

I’ve been working on a muscle system for a while on my game but struggled with making the individual parts grow with the stats specific to them. I recently found that you can change the Humanoids AutoScaling value to false in order to manipulate the body parts according to the stats but i end up with a squashed body:

Upper Muscle Stat:
image

Lower Muscle Stat:
image

I looked into other posts ALOT before making this one, and I saw that changing the position of the Motor6D’s that are attached to the limbs can achieve a desired result, however calculating how much spacing is required has proved extremely difficult as when each respective stat increases it would have to check for the necessary spacing for it to not be squashed. it may seem unrealistic but 2 games of reference, Mighty Omega and gFighting, have been able to implement this feature.

here is the code I have done so far in order to get the Body parts Big:

game.Players.PlayerAdded:Connect(function(plr)
	task.wait(1)
	
	local UM = plr:WaitForChild("StatFolder").MainStats.UpperMuscle
	local LM = plr:WaitForChild("StatFolder").MainStats.LowerMuscle
	
	repeat task.wait() until UM and LM
	
	local HardUM = 5000
	local HardLM = 5000 
	
	plr.CharacterAdded:Connect(function(char)
		
		task.wait(5)
		
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.AutomaticScalingEnabled = false
		
		--UpperMuscle
		local UpperTorso = char.UpperTorso
		local LowerTorso = char.LowerTorso
		local LeftUpperArm = char.LeftUpperArm
		local LeftLowerArm = char.LeftLowerArm
		local LeftHand = char.LeftHand
		local RightUpperArm = char.RightUpperArm
		local RightLowerArm = char.RightLowerArm
		local RightHand = char.RightHand
		
		--LowerMuscle
		local LeftUpperLeg = char.LeftUpperLeg
		local LeftLowerLeg = char.LeftLowerLeg
		local LeftFoot = char.LeftFoot
		local RightUpperLeg = char.RightUpperLeg
		local RightLowerLeg = char.RightLowerLeg
		local RightFoot = char.RightFoot
		
		local AddedSizeUM = (UM.Value / HardUM) * 3.75
		local AddedSizeLM = (LM.Value / HardUM) * 3.75
		
		RightUpperArm.Size = Vector3.new(RightUpperArm.Size.X + AddedSizeUM, RightUpperArm.Size.Y, RightUpperArm.Size.Z + AddedSizeUM)
		RightLowerArm.Size = Vector3.new(RightLowerArm.Size.X + AddedSizeUM, RightLowerArm.Size.Y, RightLowerArm.Size.Z + AddedSizeUM)
		RightHand.Size = Vector3.new(RightHand.Size.X + AddedSizeUM, RightHand.Size.Y, RightHand.Size.Z + AddedSizeUM)
		
		LeftUpperArm.Size = Vector3.new(LeftUpperArm.Size.X + AddedSizeUM, LeftUpperArm.Size.Y, LeftUpperArm.Size.Z + AddedSizeUM)
		LeftLowerArm.Size = Vector3.new(LeftLowerArm.Size.X + AddedSizeUM, LeftLowerArm.Size.Y, LeftLowerArm.Size.Z + AddedSizeUM)
		LeftHand.Size = Vector3.new(LeftHand.Size.X + AddedSizeUM, LeftHand.Size.Y, LeftHand.Size.Z + AddedSizeUM)
		
		UpperTorso.Size = Vector3.new(UpperTorso.Size.X + (AddedSizeUM * 2), UpperTorso.Size.Y, UpperTorso.Size.Z + AddedSizeUM)
		LowerTorso.Size = Vector3.new(LowerTorso.Size.X + (AddedSizeUM * 2), LowerTorso.Size.Y, LowerTorso.Size.Z + AddedSizeUM)
		
		RightUpperLeg.Size = Vector3.new(RightUpperLeg.Size.X + AddedSizeLM, RightUpperLeg.Size.Y, RightUpperLeg.Size.Z + AddedSizeLM)
		RightLowerLeg.Size = Vector3.new(RightLowerLeg.Size.X + AddedSizeLM, RightLowerLeg.Size.Y, RightLowerLeg.Size.Z + AddedSizeLM)
		RightFoot.Size = Vector3.new(RightFoot.Size.X + AddedSizeLM, RightFoot.Size.Y, RightFoot.Size.Z + AddedSizeLM)
		
		LeftUpperLeg.Size = Vector3.new(LeftUpperLeg.Size.X + AddedSizeLM, LeftUpperLeg.Size.Y, LeftUpperLeg.Size.Z + AddedSizeLM)
		LeftLowerLeg.Size = Vector3.new(LeftLowerLeg.Size.X + AddedSizeLM, LeftLowerLeg.Size.Y, LeftLowerLeg.Size.Z + AddedSizeLM)
		LeftFoot.Size = Vector3.new(LeftFoot.Size.X + AddedSizeLM, LeftFoot.Size.Y, LeftFoot.Size.Z + AddedSizeLM)
	end)
end)

Note: Using the BodyDepth and BodyWidth Values already in the humanoid does not give the desired result as all the body parts of the character change

It sounds like you might need to implement a system where the entire character grows proportionally, similar to how it’s done in the weight simulator games.

game.Players.PlayerAdded:Connect(function(plr)
    task.wait(1)
    
    local UM = plr:WaitForChild("StatFolder").MainStats.UpperMuscle
    local LM = plr:WaitForChild("StatFolder").MainStats.LowerMuscle
    
    repeat task.wait() until UM and LM
    
    local HardUM = 5000
    local HardLM = 5000 
    
    plr.CharacterAdded:Connect(function(char)
        
        task.wait(5)
        
        local humanoid = char:WaitForChild("Humanoid")
        humanoid.AutomaticScalingEnabled = false
        
        local AddedSizeUM = (UM.Value / HardUM) * 3.75
        local AddedSizeLM = (LM.Value / HardLM) * 3.75
        
        local ScaleFactor = 1 + (AddedSizeUM + AddedSizeLM) / 2
        
        char:SetPrimaryPartCFrame(char.PrimaryPart.CFrame * CFrame.new(0, char.PrimaryPart.Size.Y * (ScaleFactor - 1) / 2, 0))
        char:Resize(char.PrimaryPart.Size * ScaleFactor)
    end)
end)

Doing this would work for a simulator, but that’s not what I’m trying to make as the height the player has is random and the Upper and Lower Stats are supposed to reflect on the players character as it is only a way to get extra damage, other than the strike power stat, but at the cost of speed which I have already made.

Coming back to this I decided to just swallow my fear, and figured it out!

here is the code for anyone who is wondering:

game.Players.PlayerAdded:Connect(function(plr)
	task.wait(1)
	
	local UM = plr:WaitForChild("StatFolder").MainStats.UpperMuscle
	local LM = plr:WaitForChild("StatFolder").MainStats.LowerMuscle
	
	repeat task.wait() until UM and LM
	
	local HardWDUM = 10500
	local HardWDLM = 10500
	
	plr.CharacterAdded:Connect(function(char)
		
		task.wait(5)
		
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.AutomaticScalingEnabled = false
		
		--UpperMuscle
		local UpperTorso = char.UpperTorso
		local LowerTorso = char.LowerTorso
		local LeftUpperArm = char.LeftUpperArm
		local LeftLowerArm = char.LeftLowerArm
		local LeftHand = char.LeftHand
		local RightUpperArm = char.RightUpperArm
		local RightLowerArm = char.RightLowerArm
		local RightHand = char.RightHand
		
		--LowerMuscle
		local LeftUpperLeg = char.LeftUpperLeg
		local LeftLowerLeg = char.LeftLowerLeg
		local LeftFoot = char.LeftFoot
		local RightUpperLeg = char.RightUpperLeg
		local RightLowerLeg = char.RightLowerLeg
		local RightFoot = char.RightFoot
		
		local AddedWidthUM = (UM.Value / HardWDUM) * 1.75
		local AddedWidthLM = (LM.Value / HardWDUM) * 1.75
		
		local AddedDepthUM = (UM.Value / HardWDLM) * 1.05
		local AddedDepthLM = (LM.Value / HardWDLM) * 1.05
		
		RightUpperArm.Size = Vector3.new(RightUpperArm.Size.X + AddedWidthUM, RightUpperArm.Size.Y, RightUpperArm.Size.Z + AddedDepthUM)
		RightLowerArm.Size = Vector3.new(RightLowerArm.Size.X + AddedWidthUM, RightLowerArm.Size.Y, RightLowerArm.Size.Z + AddedDepthUM)
		RightHand.Size = Vector3.new(RightHand.Size.X + AddedWidthUM, RightHand.Size.Y, RightHand.Size.Z + AddedDepthUM)
		
		LeftUpperArm.Size = Vector3.new(LeftUpperArm.Size.X + AddedWidthUM, LeftUpperArm.Size.Y, LeftUpperArm.Size.Z + AddedDepthUM)
		LeftLowerArm.Size = Vector3.new(LeftLowerArm.Size.X + AddedWidthUM, LeftLowerArm.Size.Y, LeftLowerArm.Size.Z + AddedDepthUM)
		LeftHand.Size = Vector3.new(LeftHand.Size.X + AddedWidthUM, LeftHand.Size.Y, LeftHand.Size.Z + AddedDepthUM)
		
		UpperTorso.Size = Vector3.new(UpperTorso.Size.X + (AddedWidthUM * 2), UpperTorso.Size.Y, UpperTorso.Size.Z + AddedDepthUM)
		LowerTorso.Size = Vector3.new(LowerTorso.Size.X + (AddedWidthUM * 2), LowerTorso.Size.Y, LowerTorso.Size.Z + AddedDepthUM)
		
		RightUpperLeg.Size = Vector3.new(RightUpperLeg.Size.X + AddedWidthLM, RightUpperLeg.Size.Y, RightUpperLeg.Size.Z + AddedDepthLM)
		RightLowerLeg.Size = Vector3.new(RightLowerLeg.Size.X + AddedWidthLM, RightLowerLeg.Size.Y, RightLowerLeg.Size.Z + AddedDepthLM)
		RightFoot.Size = Vector3.new(RightFoot.Size.X + AddedWidthLM, RightFoot.Size.Y, RightFoot.Size.Z + AddedDepthLM)
		
		LeftUpperLeg.Size = Vector3.new(LeftUpperLeg.Size.X + AddedWidthLM, LeftUpperLeg.Size.Y, LeftUpperLeg.Size.Z + AddedDepthLM)
		LeftLowerLeg.Size = Vector3.new(LeftLowerLeg.Size.X + AddedWidthLM, LeftLowerLeg.Size.Y, LeftLowerLeg.Size.Z + AddedDepthLM)
		LeftFoot.Size = Vector3.new(LeftFoot.Size.X + AddedWidthLM, LeftFoot.Size.Y, LeftFoot.Size.Z + AddedDepthLM)
		
		for i,v in pairs(char:GetDescendants()) do
			
			if v:IsA("Motor6D") then
				
				if v.Name == "LeftShoulder" then
					
					local step = UM.Value / 21
					
					for i = 0.1, step do
						v.C0 = CFrame.new(v.C0.Position.X - 0.005, v.C0.Position.Y, v.C0.Position.Z)
					end
					
					
				end
				
				if v.Name == "RightShoulder" then

					local step = UM.Value / 21

					for i = 0.1, step do
						v.C0 = CFrame.new(v.C0.Position.X + 0.005, v.C0.Position.Y, v.C0.Position.Z)
					end


				end
				
				if v.Name == "LeftHip" then
					
					local step = LM.Value / 100

					for i = 0.1, step do
						v.C0 = CFrame.new(v.C0.Position.X - 0.007, v.C0.Position.Y, v.C0.Position.Z)
					end
					
				end
				
				if v.Name == "RightHip" then

					local step = LM.Value / 100

					for i = 0.1, step do
						v.C0 = CFrame.new(v.C0.Position.X + 0.007, v.C0.Position.Y, v.C0.Position.Z)
					end

				end
				
			end
			
		end
		
	end)
end)

this code is for when the player spawns in so if you want to update their appearance you will have make a changed function for which stat is being increased.

Note: I should probably edit it in order to make more sense but all I’m doing is changing the CFrame of the limbs Motor6D, not too hard.

However, this isn’t the final solution as different heights change how much the limbs need to be moved

Edit: False alarm code works as intended with heights it’s only when I want to update the Muscle it acts weird. for the sake of this post as I did find the solution it will be marked but anyone who wants to use the code will have to find the fix for this themselves.

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