ProfileData Documentation

ProfileData Documentaton

Documentation | Source | Demo

Functions:

--[[
	- ProfileData:DatastoreTest() : Test If DataStore Service Is Working Or Not.

	- ProfileData:GetDatastore(String) : Get A Datastore.
		- DataStore:GetData(UserObject) : Get A User's Data.
		- DataStore:SetData(UserObject, Value) : Set A User's Data
		- DataStore:DeleteData(UserObject) : Delete A User's Data
]]

Examples:

Testing DatastoreService

local ProfileData = require(script.Parent.ProfileData)

local success, fail = ProfileData:DatastoreTest() -- HERE

if not success then
	print("DataStoreService Is Not Working: "..fail)
end

if success then
	print("DataStore Service Is Working!")
end

Getting A Datastore

local ProfileData = require(script.Parent.ProfileData)

local success, fail = ProfileData:DatastoreTest()

if not success then
	print("DataStoreService Is Not Working: "..fail)
end

if success then
	game.Players.PlayerAdded:Connect(function(plr)

		local DataStore = ProfileData:GetDatastore("TestingDataStore") -- HERE

	end)
end

Getting A Player’s Data

local ProfileData = require(script.Parent.ProfileData)

local success, fail = ProfileData:DatastoreTest()

if not success then
	print("DataStoreService Is Not Working: "..fail)
end

if success then
	game.Players.PlayerAdded:Connect(function(plr)
		local DataStore = ProfileData:GetDatastore("TestingDataStore")

		local Data = DataStore:GetData(plr) -- HERE

	end)
end

Setting A Player’s Data

local ProfileData = require(script.Parent.ProfileData)

local success, fail = ProfileData:DatastoreTest()

if not success then
	print("DataStoreService Is Not Working: "..fail)
end

if success then
	game.Players.PlayerAdded:Connect(function(plr)
		local DataStore = ProfileData:GetDatastore("TestingDataStore")
		local Data = DataStore:GetData(plr)
		
		if not Data then

			DataStore:SetData(plr, { -- HERE
				Money = 900,
				Gems = 0
			})
			
		end
	end)
end

Deleting A Player’s Data

local ProfileData = require(script.Parent.ProfileData)

local success, fail = ProfileData:DatastoreTest()

if not success then
	print("DataStoreService Is Not Working: "..fail)
end

if success then
	game.Players.PlayerAdded:Connect(function(plr)
		local DataStore = ProfileData:GetDatastore("TestingDataStore")
		local Data = DataStore:GetData(plr)
		
		if Data then

			DataStore:DeleteData(plr) -- HERE

		end
	end)
end
1 Like