-
What do you want to achieve? Keep it simple and clear!
I want to achieve a saving system of my building template when a player is disconnected/leaves. -
What is the issue? Include screenshots / videos if possible!
The table that contains children returns nil even though it should return objects -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have talked to multiple people, no clear answers, also looked through the forum without any clear answer on workspace ‘unloading’
This is the code that I have written.
local RS = game:GetService('ReplicatedStorage')
local ST = RS:WaitForChild('RemEVent'):FindFirstChild('SaveTemplateBind')
local players = game:GetService('Players')
players.PlayerRemoving:Connect(function(player)
local TemplateSave = {
}
for _,placedasset_folder in pairs(workspace.LevelTemplate.ActiveAssets.PlacedAssets:GetChildren()) do
print(placedasset_folder)
local ARP = placedasset_folder:FindFirstChild('AssetRootPart',true)
local cframe = {ARP.CFrame:GetComponents()}
table.insert(TemplateSave,{cframe,placedasset_folder.name})
end
print(TemplateSave)
ST:Fire(player,TemplateSave)
end)
ST is bindable event that sends the template and the player to another serverscript that handles the datastore for this template.
This script is also located in ServerScriptService by the way.