game.Players.LocalPlayer.CharacterAdded:Connect(function()
game.ReplicatedStorage.clothesAndFootstepSoundAssigner:FireServer()
end)
This is in a local script in starterplayerscripts. It fires a remote event to add clothes, sound effects, and remove accessories of the player.
game.ReplicatedStorage.clothesAndFootstepSoundAssigner.OnServerEvent:Connect(function(plr)
print("fired")
local char = plr.Character
repeat wait() until plr:HasAppearanceLoaded() == true
--remove clothes
for i, child in pairs(char:GetDescendants()) do
print('doing thuis')
if child:IsA("Shirt") or child:IsA("ShirtGraphic") or child:IsA("Pants") then
child:Destroy()
end
--also, destroy any accessories that arent hair or hats
if child:IsA("Accessory") then
if child.AccessoryType ~= Enum.AccessoryType.Hat and child.AccessoryType ~= Enum.AccessoryType.Hair then
child:Destroy()
else
--if it doesn't get destroyed, disable cantouch
child.Handle.CanTouch = false
end
end
end
--add new ones
local shirt = Instance.new("Shirt")
shirt.ShirtTemplate = "rbxassetid://5262351881"
shirt.Parent = char
local pants = Instance.new("Pants")
pants.PantsTemplate = "rbxassetid://1137160924"
pants.Parent = char
--insert torso footstep sound
local sound = Instance.new("Sound")
sound.Name = "footstep1"
sound.Volume = .1
sound.SoundId = "rbxassetid://6563562192"
sound.Parent = char.Torso
local sound = Instance.new("Sound")
sound.Name = "footstep2"
sound.Volume = .1
sound.SoundId = "rbxassetid://6563562192"
sound.Parent = char.Torso
--insert torso crawl sound
local sound = Instance.new("Sound")
sound.Name = "crawl1"
sound.Volume = 1
sound.SoundId = "rbxassetid://9113702211"
sound.Parent = char.Torso
local sound = Instance.new("Sound")
sound.Name = "crawl2"
sound.Volume = 1
sound.SoundId = "rbxassetid://9113702211"
sound.Parent = char.Torso
end)
This is the remote event.
The top part is the most important, not the instancing of new clothes.
When I first load it, it prints “doing thius” (i spelled it wrong and cannot be bothered to fix it lol) 102 times. When I die and respawn, it does it 66 times. This leads me to believe that not all the parts of the character’s appearance have loaded in when it begins the script, DESPITE the repeat wait() at the start.
Does that mean the repeat wait() thing is actually working? Help