DataStore Not Saving/Loading?
It does not print any error whatsoever. Script is in ServerScriptStorage
of course
I added prints so it just prints the values it just prints "" and "0" "" for the StringValue
and "0" for the NumberValue
Yes I edited the values of the items so it has something to save...
002 | local DataStoreService = game:GetService( "DataStoreService" ) |
003 | local SafeStore = game.ReplicatedStorage:FindFirstChild( "PlayersData" ) |
004 | game.Players.PlayerAdded:connect( |
006 | local PlayerStore = DataStoreService:GetDataStore( tostring (Player.userId), "PlayerData" ) |
009 | local PlayerTag = Instance.new( "StringValue" ,SafeStore) |
010 | PlayerTag.Value = Player.userId |
011 | PlayerTag.Name = (Player.userId) |
012 | print (PlayerTag.Name) |
014 | local DataStore = Instance.new( "Folder" ,PlayerTag) |
015 | DataStore.Name = "Data" |
017 | local SlotHold = Instance.new( "Folder" ,DataStore) |
018 | SlotHold.Name = "SlotHold" |
020 | local SlotOne = Instance.new( "Folder" ,SlotHold) |
021 | SlotOne.Name = "Slot1" |
024 | SlotOneName.Name = "ItemName" |
025 | SlotOneName.Value = PlayerStore:GetAsync( "SlotOneName" ) |
026 | print (SlotOneName.Value) |
029 | SlotOneStock.Name = "ItemStock" |
030 | SlotOneStock.Value = PlayerStore:GetAsync( "SlotOneStock" ) |
031 | local SlotOneUsed = Instance.new( "BoolValue" ,SlotHold) |
032 | SlotOneUsed.Name = "Slot1Used" |
033 | print (SlotOneStock.Value) |
035 | local SlotOneUsedSlot = Instance.new( "StringValue" ,SlotOneUsed) |
036 | SlotOneUsedSlot.Name = "Slot" |
037 | SlotOneUsedSlot.Value = (SlotOne.Name) |
039 | if SlotOneName.Value = = "" and SlotOneStock.Value < = 0 then |
040 | SlotOneUsed.Value = false |
042 | SlotOneUsed.Value = true |
046 | local SlotTwo = Instance.new( "Folder" ,SlotHold) |
047 | SlotTwo.Name = "Slot2" |
050 | SlotTwoName.Name = "ItemName" |
051 | SlotTwoName.Value = PlayerStore:GetAsync( "SlotTwoName" ) |
052 | print (SlotTwoName.Value) |
055 | SlotTwoStock.Name = "ItemStock" |
056 | SlotTwoStock.Value = PlayerStore:GetAsync( "SlotTwoStock" ) |
057 | print (SlotTwoStock.Value) |
059 | local SlotTwoUsed = Instance.new( "BoolValue" ,SlotHold) |
060 | SlotTwoUsed.Name = "Slot2Used" |
062 | local SlotTwoUsedSlot = Instance.new( "StringValue" ,SlotTwoUsed) |
063 | SlotTwoUsedSlot.Name = "Slot" |
064 | SlotTwoUsedSlot.Value = (SlotTwo.Name) |
066 | if SlotTwoName.Value = = "" and SlotTwoStock.Value < = 0 then |
067 | SlotTwoUsed.Value = false |
069 | SlotTwoUsed.Value = true |
073 | local SlotThree = Instance.new( "Folder" ,SlotHold) |
074 | SlotThree.Name = "Slot3" |
077 | SlotThreeName.Name = "ItemName" |
078 | SlotThreeName.Value = PlayerStore:GetAsync( "SlotThreeName" ) |
079 | print (SlotThreeName.Value) |
082 | SlotThreeStock.Name = "ItemStock" |
083 | SlotThreeStock.Value = PlayerStore:GetAsync( "SlotThreeStock" ) |
084 | print (SlotThreeStock.Value) |
086 | local SlotThreeUsed = Instance.new( "BoolValue" ,SlotHold) |
087 | SlotThreeUsed.Name = "Slot3Used" |
089 | local SlotThreeUsedSlot = Instance.new( "StringValue" ,SlotThreeUsed) |
090 | SlotThreeUsedSlot.Name = "Slot" |
091 | SlotThreeUsedSlot.Value = (SlotThree.Name) |
093 | if SlotThreeName.Value = = "" and SlotThreeStock.Value < = 0 then |
094 | SlotThreeUsed.Value = false |
096 | SlotThreeUsed.Value = true |
099 | repeat wait() until SafeStore:findFirstChild(Player.userId) |
100 | local PlayerData = SafeStore:findFirstChild(Player.userId) |
101 | repeat wait() until PlayerTag:findFirstChild( "Data" ) |
103 | DataStore:Clone().Parent = Player |
106 | game.Players.PlayerRemoving:connect( function (Player) |
107 | local PlayerStore = DataStoreService:GetDataStore( tostring (Player.userId), "PlayerData" ) |
108 | local PlayerData = SafeStore:findFirstChild(Player.userId) |
109 | local PlrData = Player.Data.SlotHold |
110 | if SafeStore:findFirstChild(Player.userId) then |
111 | PlayerStore:SetAsync( "Slot1Name" , PlrData.Slot 1. ItemName.Value) |
112 | print (PlrData.Slot 1. ItemName.Value) |
113 | PlayerStore:SetAsync( "Slot1Stock" , PlrData.Slot 1. ItemStock.Value) |
114 | print (PlrData.Slot 1. ItemStock.Value) |
116 | PlayerStore:SetAsync( "Slot2Name" , PlrData.Slot 2. ItemName.Value) |
117 | print (PlrData.Slot 2. ItemName.Value) |
118 | PlayerStore:SetAsync( "Slot2Stock" , PlrData.Slot 2. ItemStock.Value) |
119 | print (PlrData.Slot 2. ItemStock.Value) |
121 | PlayerStore:SetAsync( "Slot3Name" , PlrData.Slot 3. ItemName.Value) |
122 | print (PlrData.Slot 3. ItemName.Value) |
123 | PlayerStore:SetAsync( "Slot3Stock" , PlrData.Slot 3. ItemStock.Value) |
124 | print (PlrData.Slot 3. ItemStock.Value) |
126 | SafeStore:findFirstChild(Player.userId):remove() |
127 | print (Player.Name .. " Saved" ) |
131 | game.OnClose = function () |