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 » Scripting Helpers
Home Search
 

Re: Data Stores

Previous Thread :: Next Thread 
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
16 Nov 2014 06:01 PM
I'm really having trouble with this. I've tried for a couple weeks now but still no luck.

I know it's a bit much but I really need help on this. EFLibrary is a Model in Lighting that contains another Model called Players. Once a Player joins another Model is created within the Players model with their name and containing their values which should load. And they do load correctly. The problem is once I for example change the Attack Value to lets say 100 and I exit the game. I will rejoin and wait for the data to load but it loads to the original starting value.

EFLibrary = game.Lighting:WaitForChild("EFLibrary")
EFLibrary:WaitForChild("Players")

DataStore = game:GetService("DataStoreService"):GetDataStore("DataStore")

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

local Name = Player.Name
wait(12)
local Data = EFLibrary.Players:WaitForChild(Player.Name):WaitForChild("PlayerData"):GetChildren()

for Amount = 1, #Data do
if DataStore:GetAsync(Data[Amount].Name) then
Data[Amount].Value = DataStore:GetAsync(Data[Amount].Name)
print(Name .. "'s data has been loaded! Data of " .. Data[Amount].Name)
else
print(Name .. " has no data to be loaded. Data of " .. Data[Amount].Name)
end
end
end)

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

local Name = Player.Name
wait(12)
local Data = EFLibrary.Players:WaitForChild(Player.Name):WaitForChild("PlayerData"):GetChildren()

for Amount = 1, #Data do
if DataStore:GetAsync(Data[Amount].Name) then
DataStore:SetAsync(Data[Amount].Name, Data[Amount].Value)
print(Name .. "'s data has been saved! Data of " .. Data[Amount].Name)
else
print(Name .. "'s data has failed to be saved. Data of " .. Data[Amount].Name)
end
end
end)
Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
16 Nov 2014 06:09 PM
i beg
Report Abuse
IntelligentBeing is not online. IntelligentBeing
Joined: 11 Jul 2013
Total Posts: 523
16 Nov 2014 06:31 PM
anybody :(
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
16 Nov 2014 06:38 PM
I heard using UpdateAsync instead of SetAsync will fix that.
Report Abuse
ZeveI is not online. ZeveI
Joined: 29 Sep 2012
Total Posts: 8003
16 Nov 2014 06:39 PM
I'd help but i can't script :(
nobody will help me fix this script for me ;c

function GetPlayerFromWeld(weld)
if weld.Part1 ~= nil then
local character = weld.Part1.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
if player then
return player
end
end
end
return nil
end

seat.ChildAdded:connect(function(newChild)
if newChild:IsA("Weld") then
script.Sound:Play()
local helicopter = script.parent.parent
repeat wait() until helicopter
wait(.2)
helicopter.Blade1.Transparency = 1
helicopter.Blade2.Transparency = 1
helicopter.Blade3.Transparency = 1
helicopter.Blade4.Transparency = 1
helicopter.Decal1.Decal1.Transparency = 0
helicopter.Decal1.Decal2.Transparency = 0
helicopter.Decal2.Decal1.Transparency = 0
helicopter.Decal2.Decal2.Transparency = 0

local player = GetPlayerFromWeld(newChild)
if player then
script.Sound:Play()
local helicopter = script.parent.parent
repeat wait() until helicopter
wait(.2)
helicopter.Blade1.Transparency = 1
helicopter.Blade2.Transparency = 1
helicopter.Blade3.Transparency = 1
helicopter.Blade4.Transparency = 1
helicopter.Decal1.Decal1.Transparency = 0
helicopter.Decal1.Decal2.Transparency = 0
helicopter.Decal2.Decal1.Transparency = 0
helicopter.Decal2.Decal2.Transparency = 0
end
end

seat.ChildRemoved:connect(function(oldChild)
if oldChild:IsA("Weld") then do
local helicopter = script.parent.parent
repeat wait() until helicopter
wait(.2)
helicopter.Blade1.Transparency = 0
helicopter.Blade2.Transparency = 0
helicopter.Blade3.Transparency = 0
helicopter.Blade4.Transparency = 0
helicopter.Decal1.Decal1.Transparency = 1
helicopter.Decal1.Decal2.Transparency = 1
helicopter.Decal2.Decal1.Transparency = 1
helicopter.Decal2.Decal2.Transparency = 1

local player = GetPlayerFromWeld(oldChild)
if player then
script.Sound:Pause()
end
end
end
end
end)

कोओल बेअन्स म्8 ओw अरे उ तोदज दो उ लिके म्ज सिग्ग्ज फ्र्न्द्? | cool beans m8 how are u today do u like my siggy frnd?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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