Hello,
I want to make emotes that you can acquire and equip in my game, and I also want it to save what emotes you’ve acquired and what emote you’ve equipped. It doesn’t seem to want to save that though, because whenever I changed the values to true on the server end then leave and rejoin the test mode in Studio, these values just go back to being false.
The issue as to why it’s not saving is because studio doesn’t like it when I use for statements and table.insert. I’ve been trying to figure this out all day and I really don’t want to type each individual value to store them
local stuffToSave = {}
local DS = game:GetService("DataStoreService"):GetDataStore("ClassFightingEmotes")
game.Players.PlayerAdded:Connect(function(p)
local emotes = Instance.new("Folder",p)
emotes.Name = "Emotes"
function makeThing(name)
-- local thing = Instance.new("Model",emotes)
-- thing.Name = name
local acquired = Instance.new("BoolValue",emotes)
acquired.Name = "acquired"
local Equipped = Instance.new("BoolValue",emotes)
Equipped.Name = "Equipped"
end
makeThing("testEmote")
wait(0.2)
local plrKey = "id_"..p.UserId
local GetSaved = DS:GetAsync(plrKey)
if GetSaved then
for i = 1, #stuffToSave do
print(stuffToSave[i])
stuffToSave[i] = GetSaved[#GetSaved+1]
end
print(emotes.testEmote.acquired.Value,"e")
else
local NumbersForSaving = stuffToSave
print(emotes.testEmote.acquired.Value)
DS:GetAsync(plrKey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(p)
for i, v in pairs(p.Emotes:GetChildren()) do
table.insert(stuffToSave,v.acquired.Value)
table.insert(stuffToSave,v.Equipped.Value)
end
DS:SetAsync("id_"..p.UserId, stuffToSave)
end)