There’s this module where you can save Instances into Datastores which is very useful,
it seems to work on a test server, but in an actual game it doesn’t replicate the item
It doesn’t show any errors whatsoever.
Help is appreciated!
local instanceStore = require(game.ServerScriptService.Services.Converter)
local dataService = game:GetService("DataStoreService")
local collectedData = dataService:GetDataStore("collectedCubes")
local players = game.Players
local storage = game.ReplicatedStorage.cubesFound
players.PlayerAdded:Connect(function(person)
local check, ex = pcall(function()
wait(5)
warn("i starty")
instanceStore:ConvertToInstance(collectedData:GetAsync('collectedCubes')).Parent = storage
end)
if check then
print("All collected items from "..person.UserId.." have been converted into instances.")
storage:SetAttribute("num",true)
else
warn(ex)
end
end)
for _, v in pairs(workspace.Cubes:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
local person = players:GetPlayerFromCharacter(hit.Parent)
print("Player_"..person.Name.." found a "..v.Name)
storage:SetAttribute("num",true)
v.Parent = storage
end)
end
end
players.PlayerRemoving:Connect(function(person)
if storage:GetAttribute("num") == false then
print("None SAVED.")
end
local check, errormessage = pcall(function()
collectedData:SetAsync(storage:GetChildren(), instanceStore:ConvertToSaveable(storage, true))
end)
if check then
print(person.Name.."'s data had been kept.")
else
warn(errormessage)
end
end)
The service & Module: