Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is the error in this script?

Asked by 11 years ago

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?

01StructureStore = game:GetService("DataStoreService"):GetDataStore("StructureStore")
02local structure = game:GetService("ServerStorage"):FindFirstChild("Structure_Player")
03 
04function PlayerEntered(player)
05    local key = "Structure_"..player.Name
06    repeat wait() until player.Character
07 
08    if StructureStore:GetAsync(key) ~= nil then
09        StructureStore:GetAsync(key).Parent = game.Workspace
10    else
11        local structure_clone = structure:clone()
12        structure_clone.Parent = game.Workspace
13        structure_clone.Name = "Structure_"..player.Name
14    end
15end
View all 23 lines...

1 answer

Log in to vote
0
Answered by
Asleum 135
11 years ago

Considering what the output says, the problem comes from the fact your StructureStore value is empty, wich means that game:GetService("DataStoreService"):GetDataStore("StructureStore") returned nil. My deduction is that your script simply failed at creating a data store. Did you try to launch your script in online mode ? (Sometimes, data stores can't be created while in test mode)

Ad

Answer this question