I have :LoadCharacter() on a button so when the player clicks on a button it will load their saved outfit. The problem is that every time I press it a second time it duplicates the accessories in the character and so on. I want to know how to prevent this. I tried adding a debounce to the :LoadCharacter, but I still got the same result. I also tried using player.CharacterAppearanceLoaded:wait() and it prevented the character’s appearance from loading.
I’ve seen other people have the same problem on the dev forum.
I just wrapped calls to LoadCharacter in a separate function that tests to see if it’s already been called before calling it. So essentially a debounce for LoadCharacter. Then I only use that function and don’t call LoadCharacter directly. This method may still cause problems if you have CharacterAutoLoads on.
Although if you’re just changing character appearance, you may be able to cut out LoadCharacter altogether and just use HumanoidDescription.
That snippet only sets the functionRunning variable, but it doesn’t use it. Also, you don’t need the wait since LoadCharacter yields.
Try this:
local function test(player)
if functionRunning then return end
functionRunning = true
print("loading character")
player:LoadCharacter()
functionRunning = false
end