local Emotes = {
["Rock On"] = {false,false,"http://www.roblox.com/asset/?id=17694308547"},
["Clap"] = {false,false,"http://www.roblox.com/asset/?id=17696748004"}
}
I’m working on saving an emotes system.
The problem is I’m continuing to create emotes but when I add them to the list, they don’t go to the players sessionData when every is saved using GetAsync when the player joins. The Datastore doesn’t recognize the key so it can’t be a part of the sessionData[player][“Emotes”].
local function Emotes(tab_)
tab_ = {}
for emote,value in pairs(EmotesList) do
tab_[emote] = value
end
return tab_
end
Players.PlayerAdded:Connect(function(player)
local key = tostring(player.UserId)
sessionData[player] = {}
sessionData[player]["Money"] = 0
sessionData[player]["Equipped"] = ""
sessionData[player]["Abilities"] = Abilities(sessionData[player]["Abilities"])
sessionData[player]["Kills"] = 0
sessionData[player]["Wins"] = 0
sessionData[player]["Level"] = 1
sessionData[player]["Experience"] = 0
sessionData[player]["Emotes"] = Emotes(sessionData[player]["Emotes"])
sessionData[player]["EmoteProgress"] = 2
sessionData[player]["Gamepasses"] = {
["DoubleEmotes"] = false
}
local success,result = pcall(function()
return DataStore:GetAsync(key)
end)
if success and result then
for i,v in pairs(result) do
print(i,v)
sessionData[player][i] = v
end
end
print(sessionData[player]["Emotes"])
leaderstats(player)
data(player)
task.spawn(function()
while true do
if DataStore:GetAsync(key) then
Leaderboards:Set(player,"Kills",sessionData[player]["Kills"])
Leaderboards:Set(player,"Wins",sessionData[player]["Wins"])
end
task.wait(100)
end
end)
Leveling:Init(player)
end)
I’m iterating through the sessionData and changing key to value so I don’t know how it would override a new key. Any ideas?