If thats how its setup then why not change the GetPlot function and have it return the plot the player owns?
local function GetPlot(plr)
for _, StarterPlot in pairs(workspace.Plots:GetChildren()) do
if plr and (StarterPlot.Owner.Value == plr or plr.Name) then -- If this line doesn't work, then try using just plr.Name
--Plot = StarterPlot -- We don't need this
return StarterPlot -- Return the plot
end
end
return;
end
And call it everytime you need to.
For example:
local function Save(plr)
local Key = "plr-"..plr.UserId
local Plot = GetPlot(plr) -- Get the plot the player owns
if Plot then -- Check if its not nil
local save = {}
-- whatever else was below this point
Ok I know I’ve asked a lot of questions but we are now closer to fixing the script than ever…
Now it says Argument 1 missing or nil in:
local serializedModel = game.ReplicatedStorage.BuildObjects:FindFirstChild(data.Name):Clone()
print whatever data is since its nil.
It printed this:
table: 0x520f1aaae18fa49f
Again…
Loop through data and print its contents
Example:
for Key, Value in pairs(data)do
print(Key)
print(Value)
end;
You can put that right after the if data then
statement
I added that and it printed:
I placed 2 models that are called Haybale
Could you print data.ObjectName after the if statement?
Also when you save your plot. What is this for loop printing:
for _, Saves in pairs(save) do
for _, a in pairs(Saves) do
print(a)
end
end
The savedData.ObjectName = nil… That probably the problem… and the print(a) I’m not sure since someone else told me to add that
But is it printing anything since thats what your saving?
Yea it printed nil as the ObjectName
Can you double check to see if your stuff is saving. See if "print(“Attempt save”) and print(“Attempt table.insert”) is printing.
ALSO do print(Obj) to see what the Obj is
Alright so from before A printed the objects name… And yes the print attempt table insert did print and where do I print obj?
wait the for loop before printed the objects name?
The one in function save in the for _, Saves in pairs(save)
Can you try accessing a new datastore and save new data
so just add an extra letter or something like this:
local PlotSave = DS:GetDataStore("PlotSave111")
I’m on mobile now, so its hard to see what was wrong with how your loading stuff, but just try this for now.
wild guess, but since this thread has been going on for so long without a solution I might as well give it. Are you sure the objects exist on the server? If they don’t, it would make sense the for loop isn’t doing anything, since GetChildren would return a blank table. If you want to test this, playtest, place some objects using your placing system, and switch to server and check the plot.PlacedObjects to check and make sure they exist.
If they do exist, are you sure you’re saving the correct plot?
Without more data about your game and all the systems you have in place (and the devforum is not the place to share that on), its quite hard to see what the true issue is, but hope you get something working
Its still the same even when I changed the datastore. It says still savedata.ObjectName = nil
I just want to say thanks for helping so far and if you can help finish and find a fix I would be so happy!
Can you confirm that the objects exist on the server like @Styre_x suggested because that would explain a lot.
Also no worries. Hopefully, we can figure this out.