Hi! As I was making my example game for my portfolio I needed to create a Datastore handler, so I used ProfileService and made a wrapper with OOP!
This is my first time ever using Object Oriented Programming, so it may not be 100% great, but it works.
Example Usage:
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Database = require(ServerStorage:WaitForChild("Database")) --> This Module
--
Players.PlayerAdded:Connect(function(p)
local dataObject = Database(p)
dataObject:load()
print(dataObject.Data)
end)
Functions
module(player: Player) → returns dataObject
Creates a “DataObject”
dataObject:load() → returns void
Loads the players data into the DataObject.
dataObject:unload() → returns void
Unloads the players data, you don’t need to call this when they leave, it will do it automatically.
Properties of dataObject
dataObject.player → player
dataObject.data → Saved Data
dataObject.Profile → Profile
Get it here: