Here is what it says " ServerScriptService.Tycoon Saver:24: bad argument #1 to ‘insert’ (table expected, got nil)"
Most likely you’re table hasn’t been declared yet and cannot be interpreted by the script.
Update the code… Should work now
What do you want me to update from the code? I tried your last one and it has a nil error, referring to the table not being declared yet, is there anything else you want to tell me?
I fixed that bug… From where I was declaring the variable - “InfoToSave” I forgot to declare it as a table…
Just by changing
local InfoToSave
to
local InfoToSave = {}
That is the only bug I am aware of.
yeah thanks I just realized that on my own
I am still having trouble with my script, it will not load the tycoon up properly here is the script I am using:
ServerScript In ServerScriptService
local Models = game:GetService("Workspace"):WaitForChild("Chevy", "Wall1") -- Only Part Of The Items in The Tycoon
local datastore = game:GetService("DataStoreService"):GetDataStore("TycoonSave")
game.Players.PlayerAdded:Connect(function(plr)
wait(1)
local good, info = pcall(function()
return datastore:GetAsync(plr.UserId)
end)
if good then
for i,v in pairs(info) do
local model = Models[v]
print("Tycoon Loaded")
--Load Model
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local Tycoon = workspace.VehicleDealershipTycoonKit.Factory
local InfoToSave = {}
for i,v in pairs(Tycoon.Models:GetChildren()) do
table.insert(InfoToSave, v.Name)
end
datastore:SetAsync(plr.UserId, InfoToSave)
print("Tycoon Saved")
end)
Noticed where I put --Load Model
I didn’t put in the code to actually load the tycoon into the model since its against the rules to give the complete script… Basically its just going through all of the models and cloning and parenting the models.
You also want to have all of the models grouped together into a single model for that system to work… If you know basic lua, Im sure you can convert that code to work with your needs. It was just an example on how exactly its done.
oh sorry i just realized, I am dumb.