You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to use DataStore2 to save Stats
-
What is the issue? The script is not creating a folder for Stats (or the player inventory)
-
What solutions have you tried so far? https://www.youtube.com/watch?v=hmRBvZD1pRw used this tutorial to help make the script
Here is the script
– Var
local DataStore2 = require(game.ServerScriptService.MainModule)
local MainKey = “MainKey”
DataStore2.Combine(MainKey,“Inv”,“Stats”)
– Tables
local function SetDataTable()
local UserData = {
Stats = {
[“Tix”] = 0,
[“KOs”] = 0,
[“WOs”] = 0,
},
Inv = {
["Test"] = false,
},
}
return UserData
end
game.Players.PlayerAdded:Connect(function(plr)
local UserData = DataStore2(MainKey,plr):Get(SetDataTable())
local Stats = Instance.new("Folder")
Stats.Name = "Stats"
local invfolder = Instance.new("Folder")
invfolder.Name = "Inv"
local Tix = Instance.new("IntValue")
Tix.name = "Tix"
local KOs = Instance.new("IntValue")
KOs.name = "KOs"
local WOs = Instance.new("IntValue")
WOs.name = "WOs"
local Waited5Seconds = Instance.new("BoolValue")
Waited5Seconds.name = "WaitedFor5Seconds"
local CLickedTheButton = Instance.new("BoolValue")
CLickedTheButton.Name = "ClickedTheButton"
local StatsData = DataStore2("Stats",plr)
local InvData = DataStore2("Inv",plr)
local function UpdateStats(UpdatedValue)
Tix.Value = StatsData:Get(UpdatedValue).Tix
KOs.Value = StatsData:Get(UpdatedValue).KOs
WOs.Value = StatsData:Get(UpdatedValue).WOs
end
local function UpdateAch(UpdatedValue)
Waited5Seconds.Value = InvData:Get(UpdatedValue).Waited5Seconds
CLickedTheButton.Value = InvData:Get(UpdatedValue).ClickedTheButton
end
UpdateStats(UserData.Stats)
UpdateAch(UserData.Inv)
StatsData.OnUpdate(UpdateStats)
InvData.OnUpdate(UpdateAch)
Stats.Parent = plr
invfolder.Parent = plr
Tix.Parent = Stats
WOs.Parent = Stats
KOs.Parent = Stats
Waited5Seconds.Parent = invfolder
CLickedTheButton.Parent = invfolder
while true do
wait(60)
end
end)