nothing saves

datastore = game:GetService("DataStoreService"):GetDataStore("EmotionCity1")

function joined(plr)
	if plr:WaitForDataReady() then
		local key = "emotion-".. plr.userId
		local savedvalues = datastore:GetAsync(key)
		
		if savedvalues then
			plr.PlayerGui.GuiStuff.CurrentMoney.Money.Value = savedvalues[1]
			plr.PlayerGui.ChooseGender.Gender.Value = savedvalues[2]
			plr.PlayerGui.GuiStuff.Clothing.Slot1.OutfitName.Value = savedvalues[3]
			plr.PlayerGui.GuiStuff.Clothing.Slot2.OutfitName.Value = savedvalues[4]
			plr.PlayerGui.GuiStuff.Clothing.Slot3.OutfitName.Value = savedvalues[5]
			plr.PlayerGui.GuiStuff.Clothing.Slot4.OutfitName.Value = savedvalues[6]
			plr.PlayerGui.GuiStuff.Hats.Slot1.AccessoryName.Value = savedvalues[7]
			plr.PlayerGui.GuiStuff.Hats.Slot2.AccessoryName.Value = savedvalues[8]
			plr.PlayerGui.GuiStuff.Hats.Slot3.AccessoryName.Value = savedvalues[9]
			plr.PlayerGui.GuiStuff.Hats.Slot4.AccessoryName.Value = savedvalues[10]
		else
			local valuestosave = {plr.PlayerGui.GuiStuff.CurrentMoney.Money.Value, 
								  plr.PlayerGui.ChooseGender.Gender.Value,
								  plr.PlayerGui.GuiStuff.Clothing.Slot1.OutfitName.Value,
								  plr.PlayerGui.GuiStuff.Clothing.Slot2.OutfitName.Value,
								  plr.PlayerGui.GuiStuff.Clothing.Slot3.OutfitName.Value,
								  plr.PlayerGui.GuiStuff.Clothing.Slot4.OutfitName.Value,
								  plr.PlayerGui.GuiStuff.Hats.Slot1.AccessoryName.Value,
								  plr.PlayerGui.GuiStuff.Hats.Slot2.AccessoryName.Value,
								  plr.PlayerGui.GuiStuff.Hats.Slot3.AccessoryName.Value,
			 					  plr.PlayerGui.GuiStuff.Hats.Slot4.AccessoryName.Value}
			
			datastore:SetAsync(key, valuestosave)
		end
	end
end
game.Players.PlayerAdded:connect(joined)

function left(plr)
	if plr:WaitForDataReady() then
		local key = "emotion-".. plr.userId
		
		local savedvalues = datastore:GetAsync(key)
		
		local valuestosave = {plr.PlayerGui.GuiStuff.CurrentMoney.Money.Value, 
							  plr.PlayerGui.ChooseGender.Gender.Value,
							  plr.PlayerGui.GuiStuff.Clothes.Slot1.OutfitName.Value,
							  plr.PlayerGui.GuiStuff.Clothes.Slot2.OutfitName.Value,
							  plr.PlayerGui.GuiStuff.Clothes.Slot3.OutfitName.Value,
							  plr.PlayerGui.GuiStuff.Clothes.Slot4.OutfitName.Value,
							  plr.PlayerGui.GuiStuff.Hats.Slot1.AccessoryName.Value,
							  plr.PlayerGui.GuiStuff.Hats.Slot2.AccessoryName.Value,
							  plr.PlayerGui.GuiStuff.Hats.Slot3.AccessoryName.Value,
		 					  plr.PlayerGui.GuiStuff.Hats.Slot4.AccessoryName.Value}
		
		datastore:SetAsync(key, valuestosave)
		
	end
end
game.Players.PlayerRemoving:connect(left)

2 comments

0

Please provide errors and elaborate on the problem. You have supplied 58 lines of code and "nothing saves" as context.

0

Hard to work with. +1 to omit moderation rep loss