PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

SetMetadata

This function sets custom metadata used by GlobalDataStore/SetAsync to associate metadata with a key. Metadata should be in key-value pair form.

See Also

  • Articles/Data store|Data Stores, an in-depth guide on data structure, management, error handling, etc.

Parameters

Name Type Default Description

Metadata values to set for the key.

Returns

Return Type Summary

No returns.


Code Samples


local DataStoreService = game:GetService("DataStoreService")

local experienceStore = DataStoreService:GetDataStore("PlayerExperience")

local setOptions = Instance.New("DataStoreSetOptions")
setOptions:SetMetaData({["ExperienceElement"] = "Fire"})

local success, errorMessage = pcall(function()
	experienceStore:SetAsync("User_1234", 50, {1234}, setOptions)
end)
if not success then
	print(errorMessage)
end