So my code from my Player Loader Module. Just removes player theres nothing doing to the player it just loads the items.
Code:
--// Services
local Players = game:GetService("Players")
local InsertService = game:GetService("InsertService")
local AssetService = game:GetService("AssetService")
--// Main
local PlayerLoader = {}
local repr = require(script:WaitForChild("repr"))
--// Types
export type PlayerLoaderParams = {
Character: Model?,
RigType: "R15" | "R6"?,
UseOldR15Animations: boolean?,
UseOldBodyParts: boolean?,
UsePlayerAnimations: boolean?,
UserId: number?,
UsePlayersProportions: boolean?,
ScriptConfiguration: {
HaveScripts: boolean?,
EnableAnimate: boolean?
}
}
export type AvatarLoaderParams = {
Character: Model?,
RigType: "R15" | "R6"?,
UseOldR15Animations: boolean?,
UseOldBodyParts: boolean?,
UserId: number?,
ScriptConfiguration: {
HaveScripts: boolean?,
EnableAnimate: boolean?
},
Assets: {
Male: {
BackAccessories: {},
FaceAccessories: {}
},
Female: {}
}
}
--// Helper function
local function cloneCharacterAssets(character: Model, assetList, Params: PlayerLoaderParams)
local Humanoid = character:FindFirstChildOfClass("Humanoid")
local Head = character:FindFirstChild("Head")
for _, item: Instance in ipairs(assetList) do
local clonedItem = item:Clone()
if clonedItem:IsA("Shirt") or clonedItem:IsA("Pants") or clonedItem:IsA("Accessory") then
clonedItem.Parent = character
elseif clonedItem:IsA("Folder") then
if Humanoid.RigType ~= Enum.HumanoidRigType.R6 then
if Params.UseOldBodyParts then
if item.Name == "R15Fixed" then
local BodyParts = item:GetChildren()
for i=1, #BodyParts do
local BodyPart = BodyParts[i]
Humanoid:ReplaceBodyPartR15(Enum.BodyPartR15[BodyPart.Name], BodyPart)
end
end
else
if item.Name == "R15ArtistIntent" then
local BodyParts = item:GetChildren()
for i=1, #BodyParts do
local BodyPart = BodyParts[i]
Humanoid:ReplaceBodyPartR15(Enum.BodyPartR15[BodyPart.Name], BodyPart)
end
end
end
if Params.UsePlayerAnimations then
if item.Name == "R15Anim" then
local Animations = item:GetChildren()
for i=1, #Animations do
local Animation = Animations[i]
local Animate = character:FindFirstChild("Animate")
if Animate:FindFirstChild(Animation.Name) then
Animate:FindFirstChild(Animation.Name):Destroy()
Animation.Parent = Animate
end
end
end
end
else
if item.Name == "R6" then
local BodyParts = item:GetChildren()
for i=1, #BodyParts do
local BodyPart = BodyParts[i]
BodyPart.Parent = character
end
end
end
elseif item:IsA("Decal") then
if Head:FindFirstChild("face") or Head:FindFirstChild("Face") then
Head:FindFirstChildOfClass("Decal").Texture = item.Texture
else
item.Parent = Head
end
elseif item:IsA("BodyColors") then
if character:FindFirstChildOfClass("BodyColors") then
character:FindFirstChildOfClass("BodyColors"):Destroy()
item.Parent = character
else
item.Parent = character
end
elseif item:IsA("SpecialMesh") then
if Head:FindFirstChild("Mesh") then
Head:FindFirstChild("Mesh"):Destroy()
item.Parent = Head
elseif not (item and Head:FindFirstChild("Mesh")) then
local FakeHead = script:WaitForChild("Mesh"):Clone()
FakeHead.Parent = Head
else
item.Parent = Head
end
elseif Params.UsePlayersProportions then
if item:IsA("NumberValue") or item:IsA("BoolValue") then
item.Parent = Humanoid
end
else
if item:IsA("NumberValue") then
local DefaultProportions = script:WaitForChild("R15DefaultScale"):GetChildren()
for i=1, #DefaultProportions do
local DefaultProportion = DefaultProportions[i]
if item.Name == DefaultProportion.Name then
item.Value = DefaultProportion.Value
end
item.Parent = Humanoid
end
end
end
end
end
--// Load Player
function PlayerLoader:LoadPlayerFromParams(Params: PlayerLoaderParams)
local Characters = script:WaitForChild("Characters")
local RigType = Params.RigType or "R15"
local UserId = Params.UserId or Random.new():NextInteger(9999, 1400500100)
local ScriptConfig = Params.ScriptConfiguration or { HaveScripts = false, EnableAnimate = false }
local UseOldR15Animations = Params.UseOldR15Animations
local Character = if Params.Character then Params.Character else Characters:WaitForChild(RigType):Clone()
Character.Parent = script:WaitForChild("CharactersToApply")
local R15Animations = script:WaitForChild("R15Animations")
local function resetBody()
for _, item in ipairs(Character:GetChildren()) do
if item:IsA("Accessory") or item:IsA("Accoutrement") or item:IsA("Shirt") or item:IsA("Pants") then
item:Destroy()
elseif item:IsA("Humanoid") then
local humanoid = item
if humanoid.RigType == Enum.HumanoidRigType.R15 then
for _, bodyPart in ipairs(script:WaitForChild("R15DefaultBody"):GetChildren()) do
humanoid:ReplaceBodyPartR15(Enum.BodyPartR15[bodyPart.Name], bodyPart:Clone())
end
end
for _, child in ipairs(humanoid:GetChildren()) do
if not (child:IsA("Status") or child:IsA("Animator")) then
child:Destroy()
end
end
elseif (item:IsA("Script") or item:IsA("LocalScript")) and item.Name == "Animate" then
if Character:FindFirstChildOfClass("Humanoid").RigType ~= Enum.HumanoidRigType.R6 then
item:ClearAllChildren()
local NewOrOld = R15Animations:FindFirstChild(UseOldR15Animations and "Old" or "New"):GetChildren()
for i=1, #NewOrOld do
local Either = NewOrOld[i]:Clone()
Either.Parent = item
end
end
end
end
end
task.spawn(resetBody)
local success, characterAppearanceResult = pcall(Players.GetCharacterAppearanceAsync, Players, UserId)
if not success then
warn("Error while getting character appearance")
return self:LoadPlayerFromParams(Params)
end
local success, usernameResult = pcall(Players.GetNameFromUserIdAsync, Players, UserId)
if not success then
warn("Error while getting username")
return self:LoadPlayerFromParams(Params)
end
Character:FindFirstChildOfClass("Humanoid").DisplayName = usernameResult
local playerFolder = script:WaitForChild("Players"):FindFirstChild(usernameResult) or Instance.new("Folder", script:WaitForChild("Players"))
playerFolder.Name = usernameResult
local allAppearanceResult = characterAppearanceResult:GetChildren()
for i=1, #allAppearanceResult do
local Item = allAppearanceResult[i]:Clone()
Item.Parent = playerFolder
end
cloneCharacterAssets(Character, allAppearanceResult, Params)
local Scripts = script:WaitForChild("Scripts"):GetChildren()
if ScriptConfig.HaveScripts then
for i=1, #Scripts do
local Script = Scripts[i]:Clone()
Script.Parent = Character
end
end
return Character
end
return PlayerLoader
Any Issue from this? if so please give me a solution.