Confusing Error

I keep getting this error of “String not found” and I’m confused why. Please help

Image:
image

Code:

function BodyType(Character,NewBody)
	local TweenIno = TweenInfo.new(0.5,Enum.EasingStyle.Quart,Enum.EasingDirection.Out)
	NewBody = BodyTypes:FindFirstChild(Character:GetAttribute('BodyType',NewBody)).Name
	--
	if Character.Humanoid and Character.Humanoid.Health > 0 then
		for Char,BasePart in ipairs(Character:GetChildren()) do
			if BasePart:IsA('BasePart') then
				-- Replace --
				local BasePartGoal = {Size = NewBody:FindFirstChild(BasePart.Name).Size}
				TweenService:Create(BasePart,TweenIno,BasePartGoal):Play()
				for _,M6D in ipairs(Character:WaitForChild('Torso'):GetChildren()) do
					if M6D:IsA('Motor6D') then
						-- Replace --
						local C0Goal = {C0 = NewBody:FindFirstChild('Torso'):FindFirstChild(M6D.Name).C0}
						TweenService:Create(M6D,TweenIno,C0Goal):Play()
					end
				end
			end
		end
	end
end
---

you made the NewBody a String in the line

NewBody = BodyTypes:FindFirstChild(Character:GetAttribute(‘BodyType’,NewBody)).Name

and you are trying to connect the FindFirstChild with a string.

If attributes supported OBJValues this would of been so much easier but yes. I’m trying to connect FindFirstChild to a OBJ or as you would call it a string

I’m a little confused with your variables, in the part where you connect the function, do you send a Character and a String?

Show me which line 32 is.

Yeah. I have it where. The name of the current body type selected is the Attributes value. You check for the body types name by reading off the attribute. If it finds the model with the same name it does the body change

I’ll send you the entire script.

-- Services --
local Players = game:GetService('Players')
local TweenService = game:GetService('TweenService')
local ServerStorage = game:GetService('ServerStorage')
-- Variables --
local AssetFolder = ServerStorage:WaitForChild('Assets')
local BodyTypes = AssetFolder:WaitForChild('BodyTypes')
---

-- Functions --
function Motor6D(Parent,Name,Part0,Part1,C0,C0Or,C1,C1Or)
	local Motor = Instance.new("Weld", Parent)
	Motor.Name = Name
	Motor.Part0 = Part0
	Motor.Part1 = Part1
	-- Rads --
	local C0OrRad = C0Or * math.pi / 180
	Motor.C0 = CFrame.fromOrientation(C0OrRad.X, C0OrRad.Y, C0OrRad.Z) + C0.Position
	--
	local C1OrRad = C1Or * math.pi / 180
	Motor.C1 = CFrame.fromOrientation(C1OrRad.X, C1OrRad.Y, C1OrRad.Z) + C1.Position
end
--
function BodyType(Character,NewBody)
	local TweenIno = TweenInfo.new(0.5,Enum.EasingStyle.Quart,Enum.EasingDirection.Out)
	NewBody = BodyTypes:FindFirstChild(Character:GetAttribute('BodyType',NewBody)).Name
	--
	if Character.Humanoid and Character.Humanoid.Health > 0 then
		for Char,BasePart in ipairs(Character:GetChildren()) do
			if BasePart:IsA('BasePart') then
				-- Replace --
				local BasePartGoal = {Size = NewBody:FindFirstChild(BasePart.Name).Size}
				TweenService:Create(BasePart,TweenIno,BasePartGoal):Play()
				for _,M6D in ipairs(Character:WaitForChild('Torso'):GetChildren()) do
					if M6D:IsA('Motor6D') then
						-- Replace --
						local C0Goal = {C0 = NewBody:FindFirstChild('Torso'):FindFirstChild(M6D.Name).C0}
						TweenService:Create(M6D,TweenIno,C0Goal):Play()
					end
				end
			end
		end
	end
end
---

-- Added --
Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAppearanceLoaded:Connect(function(Character)
		local Folder = Instance.new('Folder') Folder.Name = 'Hitboxes'
		-- Parts --
		local Torso,HumanoidRootPart = Character:WaitForChild('Torso'),Character:WaitForChild('HumanoidRootPart')
		local RightArm = Character:WaitForChild('Right Arm')
		-- Attributes --
		local BodyTypeAttribute = Character:SetAttribute('BodyType','FitBody')
		-- Add Boxes --
		-- Functions --
		Motor6D(RightArm,'Connect',RightArm,nil,CFrame.new(0,-1,0),Vector3.new(-90,0,0),CFrame.new(0.2,0.2,0.3),Vector3.new(26.881,-59.502,25.246))
		BodyType(Character,BodyTypeAttribute)
	end)
end)
---
local BasePartGoal = {Size = NewBody:FindFirstChild(BasePart.Name).Size}

This is line 32

try for this on line 26.

NewBody = BodyTypes:FindFirstChild(Character:GetAttribute(‘BodyType’))

send me a print of what is “BodyTypes” in explorer

(Sorry if the words seem to be confusing, I’m using a translator)

image

I think there is another error in your code, you wanted to know the size of the model?

What do you mean by that? (char 2.0)

I had it working when you when I was using “Player.Chatted” Now when I tried doing this it gving errors

And I don’t want to spam if commands for each body type

in NewBody, you wanted to use one of the models from the BodyTypes folder, in the script it is “FitBody”, and right after accessing the model you try to access the size (model.Size) and that doesn’t make sense, or I’m confusing

Thats exactly what im doing :sob: lol

show me what’s in FitBody, and what “size” you want to access.

if you want to access the model size as an integer i can do that too

Go ahead show me what that would look like

I think I understand better, you are not finding the size of a part of your player’s body in the Body model.