I’m try make a system to where I can save values being created by scripts when a RemoteEvent fires.
Here’s my current code:
local DataStoreService = game:GetService("DataStoreService")
local MyGlobalDataStore = DataStoreService:GetDataStore("GLOBALDATA")
local SCD = game.Workspace.SavedCubeDecals
game.ReplicatedStorage.textChanged.OnServerEvent:Connect(function(plr, newText)
local function GetTreeTable(SCD)
local tbl = {}
for Index, Obj in pairs(SCD:GetChildren()) do
local Descendants = GetTreeTable(Obj)
if Descendants then
tbl[Obj.Name] = Descendants
tbl[Obj.Name] = Obj.Value
end
end
return tbl
end
print(GetTreeTable(SCD))
MyGlobalDataStore:SetAsync("GLOBALDATA",GetTreeTable(SCD))
end)
``