I read up on the wiki on how to make Datastores but I am still not quite sure on how to make it and incorporate it into my GUI. What I want to do is save a variable in datastore that checks if the user has bought the hat (have it a boolean set at true/false) Help please?
EDIT: Would I want to use Datastore or would I use Data Persistance instead? I heard Data persistance is easier to use
Use something like this:
local DSS = game:GetService("DataStoreService") local datastore = DSS:GetDataStore("GeneralSaveData", "Players") function generateDataKey(player) local ret = "uid_" .. player.userId return ret end function generateDataTable(player) local dataTable = { Points = player.leaderstats.Points.Value, Wins = player.leaderstats.Wins.Value } return dataTable end function saveDataForPlayer(player) local key = generateDataKey(player) local data = generateDataTable(player) datastore:SetAsync(key, data) end game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() end) game.Players.PlayerRemoving:connect(function(player) player:WaitForDataReady() end) game.OnClose = function() wait(30) end
You may have to edit it for your purposes. Hope this helps :)