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: I need help with this bad [Moderately Easy]

Previous Thread :: Next Thread 
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
18 Dec 2016 03:10 PM
I need to fix my save script, people are complaining about data loss and idk how to solve it, i also want to change the save script so it says every 10 seconds rather than when the player leaves.

game.Players.PlayerRemoving:connect(function(p)
if p:findFirstChild("leaderstats") then
p:SaveInstance("SavedStatPNum"..tostring(game.PlaceId),p.leaderstats)
end
end)
game.Players.PlayerAdded:connect(function(p)
for k = 1, 60, 0.03 do
wait()
if p:findFirstChild("leaderstats") and p.DataReady then break end
end
local Loaded = nil
if p:findFirstChild("leaderstats") and pcall(function() Loaded = p:LoadInstance("SavedStatPNum"..tostring(game.PlaceId)) end) then
for j, v in pairs(Loaded:GetChildren()) do
pcall(function() p.leaderstats[v.Name].Value = v.Value end)
end
end
end)


Report Abuse
GraphicsSettings is not online. GraphicsSettings
Joined: 12 Sep 2013
Total Posts: 2883
18 Dec 2016 03:11 PM
This is deprecated, use Datastores.
Report Abuse
10MilesWide is not online. 10MilesWide
Joined: 06 Aug 2014
Total Posts: 2220
18 Dec 2016 03:13 PM
100k robux
Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
18 Dec 2016 03:17 PM
@10 lol

@guy above 10

idk how id do that, i read the wiki and datastores confuse me o.o


Report Abuse
GraphicsSettings is not online. GraphicsSettings
Joined: 12 Sep 2013
Total Posts: 2883
18 Dec 2016 03:23 PM
@C1OSE

Look up PeasPod tutorial on YouTube, it's very detailed and it explains how to create one.
Report Abuse
DivinePheonix is not online. DivinePheonix
Joined: 30 Mar 2011
Total Posts: 11190
18 Dec 2016 03:24 PM
Use DataStores, look at tutorials, its much easier to use
Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
19 Dec 2016 01:56 PM
im god awful at following tutorials, im more of a learner where im sharing screens on skype and someone shows me how to do it and teaches me that way, can no one do that or convert my script into a datastore? im really struggling here and i gotta get this done because im getting so many complaints on my game and theres so many ppl that are mad lol


Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
19 Dec 2016 04:34 PM
eeeeeeeeeeeeeeeee


Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
19 Dec 2016 09:41 PM
hmmm
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Dec 2016 09:44 PM
Use datastores and if its a model, save the name of the model and then load it back in.

data persistence doesn't work anymore.


Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
19 Dec 2016 09:45 PM
rip ur game
Report Abuse
vexieh is not online. vexieh
Joined: 22 Oct 2009
Total Posts: 3468
19 Dec 2016 09:46 PM
copy and paste code from google until it works 10/10
Report Abuse
HalfPinky456 is not online. HalfPinky456
Joined: 10 Apr 2011
Total Posts: 6236
19 Dec 2016 09:47 PM
try using this https://forum.roblox.com/Forum/ShowPost.aspx?PostID=201595803

attempt to call girlfriend (a nil value) | (͠≖ ͜ʖ͠≖)👌 | nothin' like a good argument ¯\_(ツ)_/¯
Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
25 Dec 2016 11:12 AM
@half eeeeeeeeeeeeeeeeeeeeh


Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
25 Dec 2016 11:14 AM
You're going to have to teach datastores to yourself, I don't think anyone here is willing to skype you to help you figure it out :(
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
25 Dec 2016 11:23 AM
Im feeling nice. btw you cant save Instances w/ datastores directly, so Im gonna change this up. local ds = ############################################################# game.Players.PlayerRemoving:connect(function(p) if p:findFirstChild("leaderstats") then for i,v in pairs(p.leaderstats:GetChildren()) do ds:SetAsync(p.Name.."_"..v.Name,v.Value) --Assuming everything in here has a value that isnt an object/instance end end end) game.Players.PlayerAdded:connect(function(p) repeat wait() until p:findFirstChild("leaderstats") for i,v in pairs(p.leaderstats:GetChildren()) do if ds:GetAsync(p.Name.."_"..v.Name) ~= nil then v.Value = ds:GetAsync(p.Name.."_"..v.Name) else print(p.Name.." has no data for "..v.Name.."!") end end end)
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
25 Dec 2016 11:25 AM
ugh


htt
ps://hasteb
in.co
m/gaguyed
aco.l
ua


Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
25 Dec 2016 06:40 PM
@al

why did u remove it? D:


Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
25 Dec 2016 06:46 PM
Remove what?


Do not give up; the beginning is always the hardest part.
Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
26 Dec 2016 11:57 AM
the pbin


Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
26 Dec 2016 12:09 PM
its still there for me


Do not give up; the beginning is always the hardest part.
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Dec 2016 03:49 PM
local ds = ############################################################## -- saving the data, will "leaderstats" still be around? game.Players.PlayerRemoving:connect(function(player) if player:FindFirstChild("leaderstats") then local data = {} for _,v in next,leaderstats:GetChildren() do -- make sure only values are in this data[v.Name] = v.Value end ds:SetAsync(player.UserId,data) end end) -- loading the data game.Players.PlayerAdded:connect(function(player) local data = ds:GetAsync(player.UserId) local stats = Instance.new("Model",player) stats.Name = "leaderstats" ############# = { {"Money","IntValue"}, {"XP","IntValue"}, {"Level","IntValue"}, {"Title","StringValue"} } for _,stat in ################## do local newStat = Instance.new(stat[2],leaderstats) newStat.Value = data[stat[1]] end end)
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
26 Dec 2016 03:50 PM
paste
bin.
com/
JLTbZ1NC

I always forget that Roblox gets triggered when you talk about datastores.


Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
27 Dec 2016 06:04 PM
@soy and i can just paste this into a regular script and its good to go in the workspace? or?
Report Abuse
C1OSE is online. C1OSE
Joined: 29 May 2011
Total Posts: 604
27 Dec 2016 06:12 PM
@soy

this error came up

19:12:09.743 - Workspace.Stats Save:27: attempt to index local 'data' (a nil value)
19:12:09.744 - Stack Begin
19:12:09.745 - Script 'Workspace.Stats Save', Line 27
19:12:09.745 - Stack End
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