You can write your topic however you want, but you need to answer these questions:
-
So the player inserts a value and i want that value to save and the values are stackable so if the player for example saves 2 values 2 different values save to the datastore
-
I dont know how to make a datastore saving with this
-
i’ve searched for alot of hours
local function saveData(player) -- The functions that saves data
local tableToSave = {
-- What to do here?
-- how to save the data if the player is adding it and making more and saving them all?
}
local success, err = pcall(function()
dataStore:SetAsync(player, tableToSave) -- Save the data with the player UserId, and the table we wanna save
end)
if success then -- If the data has been saved
print("Data has been saved!")
else -- Else if the save failed
print("Data hasn't been saved!")
warn(err)
end
end
local function onChildAdded(instance)
print(instance.Name .. " added to the workspace")
end
local cache = {}
game.ReplicatedStorage.RequestUser.OnServerEvent:Connect(function(player, number)
local video = game.ServerStorage.Video:Clone()
local data -- We will define the data here so we can use it later, this data is the table we saved
local success, err = pcall(function()
data = dataStore:GetAsync(player.UserId) -- Get the data from the datastore
end)
if success and data then
-- loading data
end
local name = player.UserId
local playername = player.Name
local success, asset = pcall(MarketPlaceService.GetProductInfo,MarketPlaceService,number)
local Name = asset.Name
wait(1)
if Name then
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(name, thumbType, thumbSize)
video.Parent = startergui.Screen.HomeScreen.Videos
video.Name = "video"..Name
video.Vidimage.Video = "rbxassetid://"..number
video.pfp.Image = content
video.person.Text = playername
video.Title.Text = Name
video.Vidimage.TimePosition = 0.1
print(number,asset.Name)
wait(1)
video.Parent.ChildAdded:Connect(onChildAdded)
wait(.01)
video.Parent = player.PlayerGui.Screen.HomeScreen.Videos
else
return print("Value Doesnt exist")
end
end)