generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Universal LoadSavedGear

Previous Thread :: Next Thread 
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
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
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
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
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
30 Jun 2015 05:20 AM
Don't just ghost view! Post some bumps pls very important!!
Report Abuse
ScriptOn is not online. 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
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image