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: Doesn't save ?

Previous Thread :: Next Thread 
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 08:14 PM
my old data loads but whenever i earn new levels and leave my game it doesn't save . when i come back there the same ones. the problem isn't the module script so whats wrong with this




local DataHandler = require(game.ReplicatedStorage.Modules.DataHandler)
local Enl = true;
local making = false

game.Players.PlayerAdded:connect(function(player)
DataHandler.LoadData(player)

local Decals = {healthPoints = "rbxassetid://", Woodcutting = "rbxassetid://576876652", Strength = "rbxassetid://131559539", Attack = "rbxassetid://131559531", Defence = "rbxassetid://131559534"}
local Dead = Instance.new("Sound")
Dead.SoundId = ('###################################################################################################################local plrInv = player.Stats


local LevelUp = function(v)
game.ReplicatedStorage.Events.LEVEL:FireClient(player, v)
end


local Load = function()
game.ReplicatedStorage.Events.LOAD:FireClient(player)
player.Character.Humanoid.JumpPower = 0
player.Stats.Special.ForceStop.Value = false
Inv =player:WaitForChild("Stats")
Inv.healthPoints.health.Value = Inv.healthPoints.Level.Value
Inv.healthPoints.Effect.Value = Inv.healthPoints.health.Value
end
Load()

GetSum = function()
local total = 0
for i,v in next, Inv:GetChildren() do
total = total + v.Level.Value
end
--player.PlayerGui.MainGui.Main.frm_skills.All.Text = 'Total Level: '..total
return total
end

name = function(v)
Le##########end

local SoundFade = function(sound)
while wait(0.075) do
sound.Volume = sound.Volume - 0.01
if sound.Volume <= 0
then
sound:Destroy()
end
end
wait(5)
sound:Destroy()
end


player.CharacterAdded:connect(function(character)
Load()
player:WaitForChild("Stats").Special.ForceStop.Value = false
Inv.healthPoints.health.Value = Inv.healthPoints.Level.Value
plrInv.healthPoints.Effect.Value = plrInv.healthPoints.health.Value
GetSum()

game.ReplicatedStorage.Events.CHARADDED:FireClient(player)
end)

game.ReplicatedStorage.Events.XP:FireClient(player)
end)

game.ReplicatedStorage.OX.OnServerEvent:connect(function(player, v)
name(v)
end)

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 08:26 PM
its supposed to at the end . it worked before idk what happened
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 09:19 PM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 09:45 PM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 09:53 PM
n
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 10:11 PM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 10:23 PM
bump
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
10 Sep 2017 11:04 PM
vb
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 12:04 AM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 01:50 AM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 03:07 AM
bump
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 04:12 AM
b
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
11 Sep 2017 04:37 AM
any errors?
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 05:03 AM
none
Report Abuse
gohan31865 is not online. gohan31865
Joined: 30 Jan 2011
Total Posts: 895
11 Sep 2017 05:51 AM
if ur testing in solo or testing mode then it may not work unless u have an autosave function somewhere


when u leave the game in solo mode or testing mode ur not necessarily leaving the game, so it doesnt fire such an event

also could u give us some context as to why u need the game.OnClose function?
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
11 Sep 2017 06:08 AM
this isn't the reason why your script doesn't work, but uhh...

OnClose is deprecated
http://wiki.roblox.com/index.php?title=API:Class/DataModel/OnClose

you should be using BindToClose instead
http://wiki.roblox.com/index.php?title=API:Class/DataModel/BindToClose
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 12:48 PM
Its old lol how do i use those , and im testing in game
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 01:00 PM
It worked before i made the script fe
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
11 Sep 2017 01:08 PM
What is v that is being passed on through the RemoteEvent? What is the data type?

Table, Instance, IntValue, String??
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 01:20 PM
in the module script




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
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
11 Sep 2017 01:56 PM
b
Report Abuse
RaTheKush is not online. RaTheKush
Joined: 12 Dec 2014
Total Posts: 1978
12 Sep 2017 01:53 AM
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