Hi, I'm having a problem with this code.
I'm testing on saving parts using Data Stores, but when I start a server and start a new player into the server, the output returns an error that I believe has been already fixed.
This picture is what the output returned.
This picture displays the hierarchy of the Explorer.
Note: There is just a bunch of parts inside the model that is inside the ServerStorage.
Do you know the solution to fix the error?
StructureStore = game:GetService("DataStoreService"):GetDataStore("StructureStore")
local structure = game:GetService("ServerStorage"):FindFirstChild("Structure_Player")
function PlayerEntered(player)
local key = "Structure_"..player.Name
repeat wait() until player.Character
if StructureStore:GetAsync(key) ~= nil then
StructureStore:GetAsync(key).Parent = game.Workspace
else
local structure_clone = structure:clone()
structure_clone.Parent = game.Workspace
structure_clone.Name = "Structure_"..player.Name
end
end
function PlayerLeaving(plr)
local key = "Structure_"..plr.Name
StructureStore:SetAsync(key, game.Workspace["Structure_"..plr.Name])
end
game.Players.PlayerAdded:connect(PlayerEntered)
game.Players.PlayerRemoving:connect(PlayerLeaving)
