|
| 29 Jul 2015 11:50 AM |
| Does it carry on between places in a universe? |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 11:52 AM |
| good question, i asked this a while back and someone said yes :) |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 11:54 AM |
It can save itself in one game.
Data stores are much better. |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 12:00 PM |
So how would one turn this data persistence script into a datastore?
-------------------------------------[[ SAVING ]]-------------------------------------- function saveHair(player, playerHair) player:SaveNumber("Hair", playerHair) end
-------------------------------------[[ LOADING ]]------------------------------------- function loadHair(player, Hair) local playerHair = player:LoadNumber("Hair")
if playerHair ~= 0 then Hair.Value = playerHair else print("No hair to load") end
end
-------------------------------------[[ STARTING ]]------------------------------------ function onPlayerEntered(newPlayer)
local custom = Instance.new("IntValue") custom.Name = "Customisation" local Hair = Instance.new("IntValue") Hair.Name = "Hair" Hair.Value = 0
custom.Parent = newPlayer Hair.Parent = custom
newPlayer:WaitForDataReady()
-- try loading the player's score loadHand(newPlayer, Hand) loadRace(newPlayer, Race) loadKi(newPlayer, Ki) loadP(newPlayer, P) loadPxp(newPlayer, Pxp) loadPLvl(newPlayer, PLvl) loadHair(newPlayer, Hair) loadHairCol(newPlayer, HairCol) loadTop(newPlayer, Top) loadBottom(newPlayer, Bottom) loadBuild(newPlayer, Build) end
-------------------------------------[[ AUTOSAVE ]]------------------------------------
function onPlayerRemoving(player) print("Attempting to save score for " .. player.Name) local custom = player:FindFirstChild("Customisation") if (custom ~= nil) then local Hair = custom:FindFirstChild("Hair") if (Hair ~= nil) then saveHair(player, Hair.Value) end end end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerRemoving) |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 12:03 PM |
DS > DP
http://www.roblox.com/Forum/ShowPost.aspx?PostID=161921763#161924571 |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 12:04 PM |
| http://wiki.roblox.com/index.php?title=Data_store |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 12:04 PM |
| TO SAVE IT TO DATA STORE DO THE DATA SAVING STORE THING AND THERE U GO IT IS SAVED INSIDE OR ON TOP OF THE DATA STORE |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Jul 2015 12:04 PM |
| @Geo I've already seen that, but it's too complicated e.e |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 12:07 PM |
local DS = game:GetService("DataStoreService"):GetDataStore("Hair")
-------------------------------------[[ SAVING ]]-------------------------------------- function saveHair(player, playerHair) DS:SetAsync("Hair_"..player.userId, playerHair) end
-------------------------------------[[ LOADING ]]------------------------------------- function loadHair(player, Hair) local playerHair = DS:GetAsync("Hair_"..player.userId)
if playerHair ~= nil then Hair.Value = playerHair else print("No hair to load") end
end
-------------------------------------[[ STARTING ]]------------------------------------ function onPlayerEntered(newPlayer)
local custom = Instance.new("IntValue") custom.Name = "Customisation" local Hair = Instance.new("IntValue") Hair.Name = "Hair" Hair.Value = 0
custom.Parent = newPlayer Hair.Parent = custom
-- try loading the player's score loadHand(newPlayer, Hand) loadRace(newPlayer, Race) loadKi(newPlayer, Ki) loadP(newPlayer, P) loadPxp(newPlayer, Pxp) loadPLvl(newPlayer, PLvl) loadHair(newPlayer, Hair) loadHairCol(newPlayer, HairCol) loadTop(newPlayer, Top) loadBottom(newPlayer, Bottom) loadBuild(newPlayer, Build) end
-------------------------------------[[ AUTOSAVE ]]------------------------------------
function onPlayerRemoving(player) print("Attempting to save score for " .. player.Name) local custom = player:FindFirstChild("Customisation") if (custom ~= nil) then local Hair = custom:FindFirstChild("Hair") if (Hair ~= nil) then saveHair(player, Hair.Value) end end end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerRemoving)
Something like that |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 01:32 PM |
| Thanks war, that's exactly how you do it :) |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 01:34 PM |
| Np, glad I was able to help :D |
|
|
| Report Abuse |
|
|