integrating tables with the normal Datastore is important but what about Datastore2
- First setting up the table
local DataStore2 = require(1936396537)
local defaultValue = 0
--table
game.Players.PlayerAdded:Connect(function(plr)
local PlayerData = {["Money"]=DataStore2("Money", plr),
["Power"]=DataStore2("Power", plr)}
end)
- Next LeaderBoard if you want
- Also update the LeaderBoard
game.Players.PlayerAdded:Connect(function(plr)
local PlayerData = {["Money"]=DataStore2("Money", plr),
["Power"]=DataStore2("Power", plr)}
--leaderboard
local stats = Instance.new("Folder",plr);stats.Name = "leaderstats"
for i,v in pairs(PlayerData)do
local value = Instance.new("IntValue",stats);
value.Name=i;
end
--Update leaderboard
for i,v in pairs(PlayerData)do
local function DataUpdate(DataValue)
plr.leaderstats[i].Value = PlayerData[i]:Get(DataValue)
end
DataUpdate(defaultValue)
PlayerData[i]:OnUpdate(DataUpdate)
end
end)
- Simple Click Block For testing
--I but this within the same script but all you have to do is make sure you have
--|local DataStore2 = require(1936396537)| and you should be good both ways :)
workspace.ClickPart.ClickDetector.MouseClick:Connect(function(plr)
local PlayerData = {["Money"]=DataStore2("Money", plr),
["Power"]=DataStore2("Power", plr)}
PlayerData["Money"]:Increment(50,defaultValue)
PlayerData["Power"]:Increment(5,defaultValue)
end)
simple helpful tutorial any question just ask me on devform @PhantumDev maybe able to help