I'm not for sure if it's not saving or not loading, due to the fact i have a pcall set up and it runs save successful and loading successful. It's a super simple script, and I have Api services turned on Aswell! I'm new to Datastore services, and I've done research on a ton of datastores setup multiple ways, but none seem to work for me!!
Current leaderstats\DataSaving Script
local player = game:GetService('Players') local dss = game:GetService("DataStoreService") local dataStore = dss:GetDataStore("clickData") player.PlayerAdded:Connect(function(plr) print(plr.Name..plr.UserId.." Has Been Added to the Game") local leaderstats = Instance.new("Folder",plr) leaderstats.Name = "leaderstats" local clicks = Instance.new("IntValue", leaderstats) clicks.Name = "Clicks" clicks.Value = 0 local data local succ, err = pcall(function() data = dataStore:GetAsync( "player_"..plr.UserId) end) if succ then print("DataLoaded!") clicks.Value = data else print("DataNotSaved") warn(err) end end) player.PlayerRemoving:Connect(function(plr) local data local succ, err = pcall(function() data = dataStore:SetAsync( "player_"..plr.UserId, plr.leaderstats.Clicks.Value) end) if succ then print("DataSaved") else print("SaveFailed") warn(err) end end)
Previous Script
local player = game:GetService('Players') local dss = game:GetService("DataStoreService") local dataStore = dss:GetDataStore("clickData") player.PlayerAdded:Connect(function(plr) print(plr.Name..plr.UserId.." Has Been Added to the Game") local leaderstats = Instance.new("Folder",plr) leaderstats.Name = "leaderstats" local clicks = Instance.new("IntValue", leaderstats) clicks.Name = "Clicks" clicks.Value = 0 local data local plrid = plr.UserId local succ, err = pcall(function() data = dataStore:GetAsync( "player_"..plrid) end) if succ then print("DataLoaded!") clicks.Value = data else print("DataNotSaved") warn(err) end end) player.PlayerRemoving:Connect(function(plr) local data local plrid = plr.UserId local succ, err = pcall(function() data = dataStore:SetAsync( "player_"..plrid, plr.leaderstats.Clicks.Value) end) if succ then print("DataSaved") else print("SaveFailed") warn(err) end end)
Change PlrId_fordata to "player_"..plrid idk why but that fixes it