|
| 30 Jul 2015 09:26 PM |
I'm getting so annoyed right now, I transferred from data persistence to data store and it's really aggravating me because it loads some random stuff sometimes which is not what was supposed to be saved, this doesn't happen with data persistence. How would I fix this!? Here's the script if you need it
local HDS = game:GetService("DataStoreService"):GetDataStore("Hair") local HCDS = game:GetService("DataStoreService"):GetDataStore("HairCol") local FDS = game:GetService("DataStoreService"):GetDataStore("Face") local BCDS = game:GetService("DataStoreService"):GetDataStore("BColor")
-------------------------------------[[ SAVING ]]--------------------------------------
function saveRace(player, playerRace) player:SaveNumber("Race", playerRace) end
function saveKi(player, playerKi) player:SaveNumber("Ki", playerKi) end
function saveHand(player, playerHand) player:SaveNumber("Hand", playerHand) end
function saveP(player, playerP) player:SaveNumber("Level", playerP) end function savePxp(player, playerPxp) player:SaveNumber("EXP", playerPxp) end
function savePLvl(player, playerPLvl) player:SaveNumber("PowerLvl", playerPLvl) end
function saveHair(player, playerHair) HDS:SetAsync("Hair_"..player.userId, playerHair) end
function saveHairCol(player, playerHairCol) HCDS:SetAsync("HairCol_"..player.userId, playerHairCol) end
function saveFace(player, playerFace) FDS:SetAsync("Face_"..player.userId, playerFace) end
function saveBColor(player, playerBColor) BCDS:SetAsync("BColor_"..player.userId, playerBColor) end
function saveTop(player, playerTop) player:SaveNumber("Top", playerTop) end
function saveBottom(player, playerBottom) player:SaveNumber("Bottom", playerBottom) end
-------------------------------------[[ LOADING ]]-------------------------------------
function loadRace(player, Race) local playerRace = player:LoadNumber("Race")
if playerRace ~= 0 then Race.Value = playerRace else print("Nothing to load") end
end
function loadKi(player, Ki) local playerKi = player:LoadNumber("Ki")
if playerKi ~= 0 then Ki.Value = playerKi else print("Nothing to load") end
end
function loadHand(player, Hand) local playerHand = player:LoadNumber("Hand") if playerHand ~= 0 then Hand.Value = playerHand else print("Nothing to load") end
end
function loadP(player, P) local playerP = player:LoadNumber("Level")
if playerP ~= 0 then P.Value = playerP else print("Nothing to load") end
end function loadPxp(player, Pxp) local playerPxp = player:LoadNumber("EXP") Pxp.Value = playerPxp if playerPxp ~= 0 then Pxp.Value = playerPxp else print("Nothing to load") end end
function loadPLvl(player, PLvl) local playerPLvl = player:LoadNumber("PowerLvl")
if playerPLvl ~= 0 then PLvl.Value = playerPLvl else print("Nothing to load") end
end
function loadHair(player, Hair) local playerHair = HDS:GetAsync("Hair_"..player.userId)
if playerHair ~= 0 then Hair.Value = playerHair else print("No hair to load") end
end
function loadHairCol(player, HairCol) local playerHairCol = HCDS:GetAsync("HairCol_"..player.userId)
if playerHairCol ~= 0 then HairCol.Value = playerHairCol else print("No hair color to load") end
end
function loadFace(player, Face) local playerFace = FDS:GetAsync("Face_"..player.userId)
if playerFace ~= 0 then Face.Value = playerFace else print("No face to load") end
end
function loadBColor(player, BColor) local playerBColor = BCDS:GetAsync("BColor_"..player.userId)
if playerBColor ~= 0 then BColor.Value = playerBColor else print("No BColor to load") end
end
function loadTop(player, Top) local playerTop = player:LoadNumber("Top")
if playerTop ~= 0 then Top.Value = playerTop else print("No top to load") end
end
function loadBottom(player, Bottom) local playerBottom = player:LoadNumber("Bottom")
if playerBottom ~= 0 then Bottom.Value = playerBottom else print("No bottom to load") end
end -------------------------------------[[ STARTING ]]-------------------------------------
function PxpChanged(player, Pxp, P) if Pxp.Value >= (P.Value*(P.Value+1))*84 then Pxp.Value = Pxp.Value - (P.Value*(P.Value+1))*84 P.Value = P.Value + 1 end end
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue") stats.Name = "Data" local custom = Instance.new("IntValue") custom.Name = "Customisation" local Hair = Instance.new("IntValue") Hair.Name = "Hair" Hair.Value = 0 local HairCol = Instance.new("IntValue") HairCol.Name = "HairCol" HairCol.Value = 0 local Face = Instance.new("IntValue") Face.Name = "Face" Face.Value = 0 local BColor = Instance.new("IntValue") BColor.Name = "BColor" BColor.Value = 0 local Top = Instance.new("IntValue") Top.Name = "Top" Top.Value = 0 local Bottom = Instance.new("IntValue") Bottom.Name = "Bottom" Bottom.Value = 0
local Race = Instance.new("IntValue") Race.Name = "Race" Race.Value = 0
local Ki = Instance.new("IntValue") Ki.Name = "Ki" Ki.Value = 0
local Hand = Instance.new("IntValue") Hand.Name = "Hand" Hand.Value = 0
local P = Instance.new("IntValue") P.Name = "Level" P.Value = 1 local Pxp = Instance.new("IntValue") Pxp.Name = "EXP" Pxp.Value = 0
local PLvl = Instance.new("IntValue") PLvl.Name = "PowerLvl" PLvl.Value = 52613
-------------------------------------------------------------------
Race.Parent = stats Ki.Parent = stats Hand.Parent = stats P.Parent = stats Pxp.Parent = P PLvl.Parent = stats stats.Parent = newPlayer custom.Parent = newPlayer Hair.Parent = custom HairCol.Parent = custom Top.Parent = custom Bottom.Parent = custom Face.Parent = custom BColor.Parent = custom
Pxp.Changed:connect(function() PxpChanged(newPlayer, Pxp, P) PLvl.Value = (P.Value)*52613 end)
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) loadFace(newPlayer, Face) loadBColor(newPlayer, BColor) end
-------------------------------------[[ AUTOSAVE ]]-------------------------------------
function onPlayerRemoving(player) print("Attempting to save score for " .. player.Name) local stats = player:FindFirstChild("Data") local custom = player:FindFirstChild("Customisation") if (stats ~= nil) then local Race = stats:FindFirstChild("Race") if (Race ~= nil) then saveRace(player, Race.Value) end local Ki = stats:FindFirstChild("Ki") if (Ki ~= nil) then saveKi(player, Ki.Value) end local Hand = stats:FindFirstChild("Hand") if (Hand ~= nil) then saveHand(player, Hand.Value) end
local P = stats:FindFirstChild("Level") if (P ~= nil) then saveP(player, P.Value) local Pxp = P:FindFirstChild("EXP") if (Pxp ~= nil) then savePxp(player, Pxp.Value) end end
local PLvl = stats:FindFirstChild("PowerLvl") if (PLvl ~= nil) then savePLvl(player, PLvl.Value) end local Hair = custom:FindFirstChild("Hair") if (Hair ~= nil) then saveHair(player, Hair.Value) end local HairCol = custom:FindFirstChild("HairCol") if (HairCol ~= nil) then saveHairCol(player, HairCol.Value) end local Face = custom:FindFirstChild("Face") if (Face ~= nil) then saveFace(player, Face.Value) end local BColor = custom:FindFirstChild("BColor") if (BColor ~= nil) then saveBColor(player, BColor.Value) end local Top = custom:FindFirstChild("Top") if (Top ~= nil) then saveTop(player, Top.Value) end local Bottom = custom:FindFirstChild("Bottom") if (Bottom ~= nil) then saveBottom(player, Bottom.Value) end end end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerRemoving) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:30 PM |
Very long script, where do you think the issue is?
it been looooong dai witout u me frend but i tel u al bout it wen i se u gain |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:41 PM |
| I don't know, it's just that when I go into my game, change some of the parameters, leave 3 seconds later then come back to see my character looking completely different........................... |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Jul 2015 09:44 PM |
I checked the console
"Players.myactivetestplace.PlayerGui.LoadGui.Main:65" attempt to index field Parent (a nil value) |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:45 PM |
Nothing in output...
I just read this in wiki
"GetAsync Variant GlobalDataStore:GetAsync( string key )
Returns the value of the entry in the DataStore with the given key. If the key does not exist, returns nil. This function caches for about 10 seconds: you cannot be sure that this function returns the actual value saved on the roblox servers."
How do I make sure the value saves immediately and when I want to load it I actually load the value saved? |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:46 PM |
| @Myactive that error has nothing to do with this script |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:53 PM |
| Bump, please help e.e, I'm thinking of going back to data persistence, because this is just crazy..... Does data persistence save between places in universes? |
|
|
| Report Abuse |
|
|
iiEssence
|
  |
| Joined: 18 Jun 2014 |
| Total Posts: 3467 |
|
|
| 30 Jul 2015 09:54 PM |
Only datastore saves within universe
I don't need a siggy |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:55 PM |
Please help me fix then ;(
Why does it come up with a random number some times? |
|
|
| Report Abuse |
|
|
Dynerov
|
  |
| Joined: 21 Jul 2014 |
| Total Posts: 14682 |
|
|
| 30 Jul 2015 09:55 PM |
| It's still using "SaveNumber" or so forth. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 09:56 PM |
I have only changed this to datastore since I don't need anything else to save at the moment
function saveHair(player, playerHair) HDS:SetAsync("Hair_"..player.userId, playerHair) end
function saveHairCol(player, playerHairCol) HCDS:SetAsync("HairCol_"..player.userId, playerHairCol) end
function saveFace(player, playerFace) FDS:SetAsync("Face_"..player.userId, playerFace) end
function saveBColor(player, playerBColor) BCDS:SetAsync("BColor_"..player.userId, playerBColor) end |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 10:03 PM |
It only saves the hair value for some reason... And it loads everything else from some old value for some reason, I'm so annoyed right now, please help I've been trying to fix this for like 2 hours now...
Before I left the game:
http://prntscr.com/7z33cd
After I rejoined:
http://prntscr.com/7z340c |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 10:39 PM |
| the mouse was glitchy for me i couldnt press anything |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 10:43 PM |
| You can only press Play, New Game and the arrows after the game loads. Try again, I really need help with this e.e it's already 4:42 AM, I've been trying to fix this all night |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Jul 2015 11:07 PM |
| Looks like dragonball to me c: |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 30 Jul 2015 11:39 PM |
You need to:
1. Delete ALL of that 2. Rewrite it without data persistence 3. Learn how to use datastores |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2015 11:45 PM |
Ok so i rewrote it without data persistence, but now it doesn't save at all..... omg
local DataStore = game:GetService("DataStoreService"):GetDataStore("Customisation")
-------------------------------------[[ SAVING ]]--------------------------------------
function saveRace(player, playerRace) DataStore:SetAsync("Race"..player.userId, playerRace) end
function saveP(player, playerP) DataStore:SetAsync("Level"..player.userId, playerP) end function savePxp(player, playerPxp) DataStore:SetAsync("EXP"..player.userId, playerPxp) end
function savePLvl(player, playerPLvl) DataStore:SetAsync("PowerLvl"..player.userId, playerPLvl) end
function saveHair(player, playerHair) DataStore:SetAsync("Hair"..player.userId, playerHair) end
function saveHairCol(player, playerHairCol) DataStore:SetAsync("HairCol"..player.userId, playerHairCol) end
function saveFace(player, playerFace) DataStore:SetAsync("Face"..player.userId, playerFace) end
function saveBColor(player, playerBColor) DataStore:SetAsync("BColor"..player.userId, playerBColor) end
function saveTop(player, playerTop) DataStore:SetAsync("Top"..player.userId, playerTop) end
function saveBottom(player, playerBottom) DataStore:SetAsync("Bottom"..player.userId, playerBottom) end
-------------------------------------[[ LOADING ]]-------------------------------------
function loadRace(player, Race) local playerRace = DataStore:GetAsync("Race"..player.userId)
if playerRace ~= 0 then Race.Value = playerRace else print("Nothing to load") end
end
function loadP(player, P) local playerP = DataStore:GetAsync("Level"..player.userId)
if playerP ~= 0 then P.Value = playerP else print("Nothing to load") end
end function loadPxp(player, Pxp) local playerPxp = DataStore:GetAsync("EXP"..player.userId) Pxp.Value = playerPxp if playerPxp ~= 0 then Pxp.Value = playerPxp else print("Nothing to load") end end
function loadPLvl(player, PLvl) local playerPLvl = DataStore:GetAsync("PowerLvl"..player.userId)
if playerPLvl ~= 0 then PLvl.Value = playerPLvl else print("Nothing to load") end
end
function loadHair(player, Hair) local playerHair = DataStore:GetAsync("Hair"..player.userId)
if playerHair ~= 0 then Hair.Value = playerHair else print("No hair to load") end
end
function loadHairCol(player, HairCol) local playerHairCol = DataStore:GetAsync("HairCol"..player.userId)
if playerHairCol ~= 0 then HairCol.Value = playerHairCol else print("No hair color to load") end
end
function loadFace(player, Face) local playerFace = DataStore:GetAsync("Face"..player.userId)
if playerFace ~= 0 then Face.Value = playerFace else print("No face to load") end
end
function loadBColor(player, BColor) local playerBColor = DataStore:GetAsync("BColor"..player.userId)
if playerBColor ~= 0 then BColor.Value = playerBColor else print("No BColor to load") end
end
function loadTop(player, Top) local playerTop = DataStore:GetAsync("Top"..player.userId)
if playerTop ~= 0 then Top.Value = playerTop else print("No top to load") end
end
function loadBottom(player, Bottom) local playerBottom = DataStore:GetAsync("Bottom"..player.userId)
if playerBottom ~= 0 then Bottom.Value = playerBottom else print("No bottom to load") end
end
-------------------------------------[[ STARTING ]]-------------------------------------
function PxpChanged(player, Pxp, P) if Pxp.Value >= (P.Value*(P.Value+1))*84 then Pxp.Value = Pxp.Value - (P.Value*(P.Value+1))*84 P.Value = P.Value + 1 --PLvl.Value = (P.Value * A.Value * C.Value)*50 end end
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue") stats.Name = "Data" local custom = Instance.new("IntValue") custom.Name = "Customisation" local Hair = Instance.new("IntValue") Hair.Name = "Hair" Hair.Value = 0 local HairCol = Instance.new("IntValue") HairCol.Name = "HairCol" HairCol.Value = 0 local Face = Instance.new("IntValue") Face.Name = "Face" Face.Value = 0 local BColor = Instance.new("IntValue") BColor.Name = "BColor" BColor.Value = 0 local Top = Instance.new("IntValue") Top.Name = "Top" Top.Value = 0 local Bottom = Instance.new("IntValue") Bottom.Name = "Bottom" Bottom.Value = 0
local Race = Instance.new("IntValue") Race.Name = "Race" Race.Value = 0
local P = Instance.new("IntValue") P.Name = "Level" P.Value = 1 local Pxp = Instance.new("IntValue") Pxp.Name = "EXP" Pxp.Value = 0
local PLvl = Instance.new("IntValue") PLvl.Name = "PowerLvl" PLvl.Value = 52613
------------------------------------------------------------------
Race.Parent = stats P.Parent = stats Pxp.Parent = P PLvl.Parent = stats stats.Parent = newPlayer custom.Parent = newPlayer Hair.Parent = custom HairCol.Parent = custom Top.Parent = custom Bottom.Parent = custom Face.Parent = custom BColor.Parent = custom
Pxp.Changed:connect(function() PxpChanged(newPlayer, Pxp, P) PLvl.Value = (P.Value)*52613 end)
newPlayer:WaitForDataReady()
-- try loading the player's score loadRace(newPlayer, Race) loadP(newPlayer, P) loadPxp(newPlayer, Pxp) loadPLvl(newPlayer, PLvl) loadHair(newPlayer, Hair) loadHairCol(newPlayer, HairCol) loadTop(newPlayer, Top) loadBottom(newPlayer, Bottom) loadFace(newPlayer, Face) loadBColor(newPlayer, BColor) end
-------------------------------------[[ AUTOSAVE ]]-------------------------------------
function onPlayerRemoving(player) print("Attempting to save score for " .. player.Name) local stats = player:FindFirstChild("Data") local custom = player:FindFirstChild("Customisation") if (stats ~= nil) then local Race = stats:FindFirstChild("Race") if (Race ~= nil) then saveRace(player, Race.Value) end
local P = stats:FindFirstChild("Level") if (P ~= nil) then saveP(player, P.Value) local Pxp = P:FindFirstChild("EXP") if (Pxp ~= nil) then savePxp(player, Pxp.Value) end end
local PLvl = stats:FindFirstChild("PowerLvl") if (PLvl ~= nil) then savePLvl(player, PLvl.Value) end local Hair = custom:FindFirstChild("Hair") if (Hair ~= nil) then saveHair(player, Hair.Value) end local HairCol = custom:FindFirstChild("HairCol") if (HairCol ~= nil) then saveHairCol(player, HairCol.Value) end local Face = custom:FindFirstChild("Face") if (Face ~= nil) then saveFace(player, Face.Value) end local BColor = custom:FindFirstChild("BColor") if (BColor ~= nil) then saveBColor(player, BColor.Value) end local Top = custom:FindFirstChild("Top") if (Top ~= nil) then saveTop(player, Top.Value) end local Bottom = custom:FindFirstChild("Bottom") if (Bottom ~= nil) then saveBottom(player, Bottom.Value) end end end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerRemoving) |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Jul 2015 11:58 PM |
| Bumping this one last time, maybe someone will help e.e I'm going to sleep for the moment |
|
|
| Report Abuse |
|
|
IRyan70
|
  |
| Joined: 08 Jun 2011 |
| Total Posts: 484 |
|
|
| 30 Jul 2015 11:59 PM |
I feel your stuggle 0_x I don't know how to use data stores, if I did I'd help you :) Good luck |
|
|
| Report Abuse |
|
|