My data store saving does not work, what do I do? [closed]
So I was using alvinblox's tutorial on how to make a simulator part 3, and I did the data store but when I join the game on roblox and get the numbers to what I want and then rejoin, it didn't save. Heres the code:
01 | local serverStorage = game:GetService( "ServerStorage" ) |
02 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "PlayerSave3" ) |
04 | game.Players.PlayerAdded:Connect( function (player) |
06 | local leaderstats = Instance.new( "Folder" ) |
07 | leaderstats.Name = "leaderstats" |
08 | leaderstats.Parent = player |
10 | local intelligence = Instance.new( "NumberValue" ) |
11 | intelligence.Name = "Intelligence" |
12 | intelligence.Parent = leaderstats |
14 | local rebirths = Instance.new( "IntValue" ) |
15 | rebirths.Name = "Rebirths" |
16 | rebirths.Parent = leaderstats |
18 | local dataFolder = Instance.new( "Folder" ) |
19 | dataFolder.Name = player.Name |
20 | dataFolder.Parent = serverStorage.RemoteData |
22 | local debounce = Instance.new( "BoolValue" ) |
23 | debounce.Name = "Debounce" |
24 | debounce.Parent = dataFolder |
26 | local intelligenceData, rebirthsData |
28 | local success,errormessage = pcall ( function () |
29 | intelligenceData = DataStore:GetAsync( "intelligence-" ..player.UserId) |
30 | rebirthsData = DataStore:GetAsync( "rebirths-" ..player.UserId) |
34 | if intelligenceData then |
35 | intelligence.Value = intelligenceData |
36 | rebirths.Value = rebirthsData |
42 | game.Players.PlayerRemoving:Connect( function (player) |
43 | local success, errormessage = pcall ( function () |
44 | DataStore:SetSync( "intelligence-" ..player.UserId,player.leaderstats.Intelligence.Value) |
45 | DataStore:SetSync( "rebirths-" ..player.UserId,player.leaderstats.Rebirths.Value) |
What is wrong here? [I did not add the size as I don't want that.]