This has proven a big challenge.
I’ve tried
characterAdded locally,
server sending characters added,
local appearanceLoaded:wait() never ends,
it is very messy, and the only solution seems to check for all characters every render frame and queue them, because although a wait(someTime) lets the baseParts load, it is unreliable, and will never be optimal.
Are you trying to create an intro?
I’m confused here…
The context of use is not necessary to formulate a solution, but I would be setting them to a collision group.
You can create a new table that’s a filtered version of GetDescendants from the character as well as check for new BasePart descendants to be added to that table. Any work that you have relating to the character’s parts can be performed as a loop through this table.
local characterParts = {}
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
table.insert(characterParts, part)
end
end
I don’t assume you add anything dynamically and I assume that all character parts will be in before this code starts executing, but you may have some leftover edge cases to account for.
CharacterAdded:Wait().DescendantAdded:Connect()
(or connect above too)
full explanation:
--when something is added to the character
local instanceAdded = function(child)
if child:IsA("BasePart") then
Physics:SetPartCollisionGroup(child, "CharacterParts")
end
end
--when a character is created, call on all baseparts and set it up for future ones
local characterAdded = function(char)
for _, item in next, char:GetDescendants() do
instanceAdded(item)
end
char.DescendantAdded:Connect(instanceAdded)
end
local playerAdded = function(player)
player.CharacterAdded:Connect(characterAdded)
end
Players.PlayerAdded:Connect(playerAdded)
Very strange error saying “DescendantAdded is not… of model”.
Disregarding that, this is correct as a server-side script, and is similar to what I came up with regarding it in the form of a localScript. The difference is in checking for parts that were present, instanced prior to the localScript itself.
Also a question: Does
local characterAdded = function(char)
have any difference from
local function characterAdded(char)
when it is ran by the machine?
You made a typo lmao
DescendantAdded
Also yes, it actually does.
local f = function()end
vs
local f
f = function()end
But I prefer writing my functions this way because they are first class in lua and when I want to do recursive calls:
local helper = function(...)
end
local function recursive(...)
helper(...)
end