What is the error in this script?
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?
01 | StructureStore = game:GetService( "DataStoreService" ):GetDataStore( "StructureStore" ) |
02 | local structure = game:GetService( "ServerStorage" ):FindFirstChild( "Structure_Player" ) |
04 | function PlayerEntered(player) |
05 | local key = "Structure_" ..player.Name |
06 | repeat wait() until player.Character |
08 | if StructureStore:GetAsync(key) ~ = nil then |
09 | StructureStore:GetAsync(key).Parent = game.Workspace |
11 | local structure_clone = structure:clone() |
12 | structure_clone.Parent = game.Workspace |
13 | structure_clone.Name = "Structure_" ..player.Name |
17 | function PlayerLeaving(plr) |
18 | local key = "Structure_" ..plr.Name |
19 | StructureStore:SetAsync(key, game.Workspace [ "Structure_" ..plr.Name ] ) |
22 | game.Players.PlayerAdded:connect(PlayerEntered) |
23 | game.Players.PlayerRemoving:connect(PlayerLeaving) |