I am working on an emote system, in order to save the emotes a player has, i thought that maybe ProfileService would be a good idea, it works just fine, saves data properly, But at the PlayerRemoving part, the method to save emotes saves them tons and tons of times all at once
Players.PlayerRemoving:Connect(function(player)
local profile = Profiles[player]
if player:FindFirstChild("Emotes") then
for i, emote in pairs(player:FindFirstChild("Emotes"):GetChildren()) do
print(emote.Name)
if allEmotes:FindFirstChild(emote.Name) then
print("Check 2")
table.insert(profile.Data.Emotes, emote.Name)
print(profile.Data.Emotes)
end
end
end
if profile ~= nil then
profile:Release()
end
end)
it prints “Check 2”, the table, and the emote names, Like 20 times.
Then when i rejoin, i have a bunch of duplicated emotes in my inventory.
Any help?
PlayerRemoving is not firing multiple times, The thing that is firing multiple times is the in pairs loop.
I have a solution that works for now, but im not sure if its the proper way to do this
Basically, it just makes a local table, and inserts the emote names in there, then sets the data emotes to that table, Is this fine to do? it works right now, or is there a better way?
When a player joins, a Server script called “DataServer” will add a folder to the player that joined called “Emotes”, Then it will get the names in Profile.Data.Emotes, and give the folder the emote object that corresponds with the name, That part works, Then, when the player leaves, It will get the names of all the emotes in the Emotes folder of the player, and place them into a table, and then set the profile data emotes to that table.
That system works perfectly, but im unsure if i should change it or not, It works, but i dont know if there’s a better way to do this.
No, The original script at the top is exactly what is in my game, which doesn’t double anything, None the less, The system im currently using works, which is making a table with the names, and setting Profile.Data.emotes directly to that table, it works perfectly, but i just need to know if theres a better way, or a more efficient way.