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
 

Data System

Previous Thread :: Next Thread 
HardCoreDev is not online. HardCoreDev
Joined: 19 Nov 2015
Total Posts: 112
09 Feb 2016 02:33 AM
local AllActiveFolders = {"PlayerAttributes","PlayerStats","PlayerChar","PlayerInven"}
local AllAttributes = {"PlayerEnergy","PlayerStamina","PlayerHealth","PlayerArmor","PlayerHunger","PlayerThirst","PlayerSpeed","PlayerStrength","PlayerMagicSkill"}
local AllStats = {"PlayerRank","PlayerXp","PlayerMission","PlayerMissionID"}
local AllInvens = {"Coal","Wood","Leather","Copper","Steel","Silver","Emerald","Ruby","Shappire","Gold","Diamond","Obsidian","DemonicStone","CurrencyCoin"}
local AllChars = {"MagicOngoing","Swordfighting","Dueling","Missioning","Shopping","Tutorialing"}

game.Players.PlayerAdded:connect(function(Player)
Player:WaitForDataReady()

local PlayerAttributes = Instance.new("Folder", Player)
PlayerAttributes.Name = "PlayerAttributes"
local PlayerStats = Instance.new("Folder", Player)
PlayerStats.Name = "PlayerStats"
local PlayerChar = Instance.new("Folder", Player)
PlayerChar.Name = "PlayerChar"
local PlayerInven = Instance.new("Folder", Player)
PlayerInven.Name = "PlayerInven"

for i,v in pairs(AllAttributes) do
local NewAttribute = Instance.new("IntValue",PlayerAttributes)
NewAttribute.Name = AllAttributes[i]
end

for i,v in pairs(AllStats) do
local NewStat = Instance.new("IntValue",PlayerStats)
NewStat.Name = AllStats[i]
end

for i,v in pairs(AllInvens) do
local NewInven = Instance.new("IntValue",PlayerInven)
NewInven.Name = AllInvens[i]
end

for i,v in pairs(AllChars) do
local NewChar = Instance.new("BoolValue",PlayerChar)
NewChar.Name = AllChars[i]
end

for i,v in pairs(Player:GetChildren()) do
for iii,vvv in pairs(AllActiveFolders) do
if v.Name == AllActiveFolders[iii] then
for ii,vv in pairs(v:GetChildren()) do
if vv.ClassName == "IntValue" then
local SavedValue = Player:LoadNumber(vv.Name)
vv.Value = SavedValue
if SavedValue == 0 then
vv.Value = 1
end
vv.Value = SavedValue
elseif vv.ClassName == "StringValue" then
local SavedValue = Player:LoadString(vv.Name)
vv.Value = SavedValue
if SavedValue == "" then
vv.Value = ""
end
vv.Value = SavedValue
elseif vv.ClassName == "BoolValue" then
local SavedValue = Player:LoadBoolean(vv.Name)
end
end
end
end
end
end)

game.Players.PlayerRemoving:connect(function(Player)
Player:WaitForDataReady()

for i,v in pairs(Player:GetChildren()) do
for iii,vvv in pairs(AllActiveFolders) do
if v.Name == AllActiveFolders[iii] then
for ii,vv in pairs(v:GetChildren()) do
if vv.ClassName == "IntValue" then
Player:SaveNumber(vv.Name, vv.Value)
elseif vv.ClassName == "StringValue" then
Player:SaveString(vv.Name, vv.Value)
elseif vv.ClassName == "BoolValue" then
Player:SaveBoolean(vv.Name, vv.Value)
end
end
end
end
end
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