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
 

doesnt load

Previous Thread :: Next Thread 
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 05:26 PM
why doesnt this load my data when i rejoin



prints loaded data



local DataHandler = require(game.ReplicatedStorage.Modules.DataHandler)

game.Players.PlayerAdded:connect(function(player)
DataHandler.LoadData(player)
print('Loaded data')


game.Players.PlayerRemoving:connect(function(player)
DataHandler.SaveData(player)
end
)

game.OnClose = function()
for i,v in next, game.Players:GetPlayers() do
DataHandler.SaveData(v)
end
end
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 05:29 PM
thats in a server script







local PlayerData = game:GetService('DataStoreService'):GetDataStore('Data048')

local DefaultStats = {
Stats = {

Special = {
ForceStop = false,
Combat = 1,
ExpNeeded = 83,
Exp = 0,
Effect = 1,
NewPlayer = 1,
Level =0,
ItemEquipted = 0
},
Attack = {
Level = 1,
ExpNeeded = 83,
Exp = 0,
Effect = 1,
PrayerExtra = 0,
ExpEarned = 0
},
Strength = {
Level = 1,
ExpNeeded = 83,
Exp = 0,
Effect = 1,
PrayerExtra = 0,
ExpEarned = 0

},
Defence = {
Level = 1,
ExpNeeded = 83,
Exp = 0,
Effect = 1,
PrayerExtra = 0,
ExpEarned = 0

},
healthPoints = {
Level = 10,
ExpNeeded = 83,
Exp = 0,
Effect = 10,
health = 10,
PrayerExtra = 0,
ExpEarned = 0
},
Woodcutting = {
Level = 1,
ExpNeeded = 83,
Exp = 0,
Effect = 1,
PrayerExtra = 0,
ExpEarned = 0
},

},
Inventory = {
InventorySlot = 0,
IVTS1 = nil,
IVTS2 = nil,
IVTS3 = nil,
IVTS4 = nil,
IVTS5 = nil,
IVTS6 = nil,
IVTS7 = nil,
IVTS8 = nil,
IVTS9 = nil,
IVTS10 = nil,
IVTS11 = nil,
IVTS12 = nil,
IVTS13 = nil,
IVTS14 = nil,
IVTS15 = nil,
IVTS16 = nil,
IVTS17 = nil,
IVTS18 = nil,
IVTS19 = nil,
IVTS20 = nil,
IVTS21 = nil,
IVTS22 = nil,
IVTS23 = nil,
IVTS24 = nil,
IVTS25 = nil,
IVTS26 = nil,
IVTS27 = nil,
IVTS28 = nil

},

}

local PlayerStats = {}

local DataHandler = {}

LoadStats = function(Player)
local UserId = Player.UserId
local PlayerStats = PlayerStats[UserId]
for stats,data in next, PlayerStats do
local NewStat = Instance.new('Folder',Player)
NewStat.Name = stats
for key,val in next, data do
if type(val) == 'table' then
local NewFolder = Instance.new('Folder',NewStat)
NewFolder.Name = key

for key,v in next, val do
if key == 'ForceStop' then
local NewVal = Instance.new('BoolValue',NewFolder)
NewVal.Name = key
NewVal.Value = v
else
local NewVal = Instance.new('IntValue',NewFolder)
NewVal.Name = key
NewVal.Value = v
end
end
else
local NewVal = Instance.new('IntValue',NewStat)
NewVal.Name = key
NewVal.Value = val
end
end
end
end

SaveStats = function(Player)
local UserId = Player.UserId
local Stats = Player:WaitForChild('Stats')
for i,val in next, Stats:GetChildren() do
if val:IsA('Folder') then
for i,v in next, val:GetChildren() do
PlayerStats[UserId][Stats.Name][val.Name][v.Name] = v.Value
end
else
PlayerStats[UserId][Stats.Name][val.Name] = val.Value
end
end
for i,v in next, PlayerStats[UserId] do
for j,k in next, v do
if type(k) == 'table' then
for key,val in next, k do
end
else
end
end
end
end

DataHandler.LoadData = function(Player)
local UserId = Player.UserId
local Data
pcall(function() Data = PlayerData:GetAsync(UserId) end)
if Data then
PlayerStats[UserId] = Data
else
local s,e = pcall(function()
PlayerData:SetAsync(UserId,DefaultStats)
end)
if not s then warn(e) end
PlayerStats[UserId] = DefaultStats
end
LoadStats(Player)
end

DataHandler.SaveData = function(Player)
local UserId = Player.UserId
SaveStats(Player)
local s,e = pcall(function()
PlayerData:SetAsync(UserId,PlayerStats[UserId])
end)
if not s then warn(e) end
end
return DataHandler
Report Abuse
chexyalani is online. chexyalani
Joined: 26 Mar 2017
Total Posts: 694
10 Sep 2017 05:30 PM
modulescript code please?
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 05:35 PM
sent
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 05:44 PM
,
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 06:13 PM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 06:32 PM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 07:08 PM
bump
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 07:38 PM
b
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