I keep getting this error of “String not found” and I’m confused why. Please help
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
---
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
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
-- 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)
---
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