TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 10 Apr 2015 05:51 PM |
Would it be possible to take the data already on a server and transfer it over to a datastore? if this is possible..then How would I be able to convert something like this over to a DataStore?
function onPlayerEntered(player) player:WaitForDataReady() if player.DataReady then if player:findFirstChild("XP") then local xp = player:findFirstChild("XP") local XPLoaded = player:LoadNumber(xp.Name) if XPLoaded ~= 0 then xp.Value = XPLoaded end
end end end
function onPlayerLeaving(player) if player:findFirstChild("XP") then local xp = player:findFirstChild("XP") player:SaveNumber(xp.Name,xp.Value) end end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerLeaving) |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 10 Apr 2015 05:51 PM |
| http://wiki.roblox.com/index.php?title=Data_store |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 06:22 PM |
local DataStoreService = game:GetService("DataStoreService") local XPDataStore = DataStoreService:GetDataStore("XP")
Also use GetAsync and SetAsync. It shouldnt be too hard. Good luck on this! |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 06:33 PM |
local DSS = game:GetService("DataStoreService")
function onPlayerEntered(player) local DS = DSS:GetDataStore(player.userId) local XPLoaded = DS:GetAsync("XP") if not XPLoaded then DS:SetAsync("XP", 0) XPLoaded = 0 end local xp = player:WaitForChild("XP") xp.Value = XPLoaded end
function onPlayerLeaving(player) local DS = DSS:GetDataStore(player.userId) local xp = player:WaitForChild("XP") DS:SetAsync("XP",xp.Value) end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerLeaving) |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 06:34 PM |
| (I didn't test the above, I wrote it off the top of my head) |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 10 Apr 2015 06:37 PM |
@OP
http://www.roblox.com/games/234837831/Datastore
There is a datastore example there.
I script -~ chimmihc |
|
|
| Report Abuse |
|
|