Does anyone know my script keep spawning the default rig first then it starting to load the actual appearance id by userid??
rig with no appearance spawning first time even though id is valid:
Then the others rigs spawn with appearance:
Code:
task.spawn(function()
while task.wait(NPCSpawnSpeed) do
if PlayersFriendsList[Plr.UserId] ~= 'N/A' then
print('Spawning...')
local PlrBuilding = BuildingsFolder:FindFirstChild(Plr.Name)
if PlrBuilding and PlrBuilding:IsA('Model') then
local NPCsFolder = PlrBuilding:FindFirstChild('NPCs')
if NPCsFolder and NPCsFolder:IsA('Folder') then
local NewRig = RigModel:Clone()
local NewRigHumanoid = RigModel:FindFirstChildWhichIsA('Humanoid')
if NewRigHumanoid then
local RandomPlrId = PlayersFriendsList[Plr.UserId][math.random(1, #PlayersFriendsList[Plr.UserId])].VisitorId
NewRig.Name = ' '
if typeof(RandomPlrId) == 'number' then
NewRigHumanoid:ApplyDescription(Players:GetHumanoidDescriptionFromUserId(RandomPlrId))
end
end
NewRig.Parent = NPCsFolder
local BuildingDoor = PlrBuilding:FindFirstChild('Door')
if BuildingDoor and BuildingDoor:IsA('BasePart') then
NewRig:PivotTo(BuildingDoor.CFrame)
end
else
warn('Cannot find NPCs folder in player building!!')
end
else
warn('Cannot find player building in buildings folder!!')
end
else
end
end
end)