|
| 30 Jun 2015 05:10 AM |
The 'gear' storage saves for when the player clicks save / load but when they join another game [universal feature] the tools don't follow through to that next portal. [GetAsync / SetAsync / player.userId / datastoreservice] = used
function playerSave(player) if not waitForDataReady(player) then tellPlayer(player, saveErrorMessage) return end local ds = game:GetService('DataStoreService'):GetDataStore('StarterGear') if (save_times[player] or 0) + 30 > tick() then tellPlayer(player, saveFastMessage) return end save_times[player] = tick()
local gear = player:findFirstChild("StarterGear") if not gear then tellPlayer(player, saveErrorMessage) return end local tools = gear:GetChildren() local worked = false pcall(function () ds:SetAsync(player.userId .. "Count", #tools) worked = true end) if not worked then tellPlayer(player, saveErrorMessage) return end for i, tool in pairs(tools) do pcall(function () player:SaveInstance(player.userId.. tostring(i), tool) end) end tellPlayer(player, saveSuccessMessage) end
function playerLoad(player) if not waitForDataReady(player) then tellPlayer(player, loadErrorMessage) return end local ds = game:GetService('DataStoreService'):GetDataStore('StarterGear') if (load_times[player] or 0) + 60*3 > tick() then tellPlayer(player, loadFastMessage) return end load_times[player] = tick()
local gear = player:findFirstChild("StarterGear") local backpack = player:findFirstChild("Backpack") local current = gear:GetChildren() local count = 0 pcall(function () count = ds:GetAsync(player.userId .. "Count") end) local tools = {} for i = 1, count do pcall(function () tools[#tools + 1] = player:LoadInstance(player.userId.. tostring(i)) end) end for i, tool in pairs(tools) do local copy = tool:clone() copy.Parent = backpack local copy2 = tool:clone() copy2.Parent = gear end if clearStarterGearOnLoad then for i, tool in pairs(current) do tool:remove() end end tellPlayer(player, loadSuccessMessage) end |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2015 05:13 AM |
bump
If you don't know how to fix it / don't see anything wrong with it the bumps will help me and your post count! |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2015 05:20 AM |
| Don't just ghost view! Post some bumps pls very important!! |
|
|
| Report Abuse |
|
|
ScriptOn
|
  |
| Joined: 22 Aug 2010 |
| Total Posts: 10885 |
|
|
| 30 Jun 2015 05:21 AM |
| Why use saveinstance? Just save the name of the tool and copy it from the server into the players backpack. Apart from that I recommend you take out all the stuff with timing and saving a certain amount of times per minute. Get the core code running then add complex features like save throttling. |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2015 05:28 AM |
If I changed it to setasync instead of saveinstance, do you think it'd have a shot at universal progress?
I've used setasync and getasync for my leaderboard statistics and they're universal working now. |
|
|
| Report Abuse |
|
|
ScriptOn
|
  |
| Joined: 22 Aug 2010 |
| Total Posts: 10885 |
|
|
| 30 Jun 2015 05:30 AM |
| I only use SetAsync because I don't trust the other method. Give that a go but it shouldn't be the reason why this is failing. |
|
|
| Report Abuse |
|
|