Error: DataStore is not a valid member or DataStoreService
Trying to make a datastore with a stat and team but get an error. Apparently DataStore (A.K.A something I was told to name whatever I wanted to) is not a valid member. Help please.
--code local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService("DataStore") local function loadStarterData(Player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = Player local Deaths = Instance.new("IntValue") Deaths.Name = "Deaths" Deaths.Parent = leaderstats end local function loadData(Player) local Data local s,e pcall(function() Data = DataStore:GetAsync("UserId:".. Player.UserId) end) if s then Player.leaderstats.Deaths.Value = Data[1] Player.Team = game.Teams[Data[1]] print("Loaded ".. Player.Name .."’s data successfully") else print("Failed to load ".. Player.Name .."’s data") end end local function saveData(Player) local Data = { Deaths = 0, Team = "" } Data.Deaths = Player.leaderstats.Deaths.Value Data.Team = Player.Team.Name local s,e pcall(function() DataStore:SetAsync("UserId:".. Player.UserId, Data) end) if s then print("Saved ".. Player.Name .."’s data successfully") else print("Failed to save ".. Player.Name .."’s data") end end game.Players.PlayerAdded:Connect(function(Player) loadStarterData(Player) loadData(Player) end) game.Players.PlayerRemoving:Connect(function(Player) saveData(Player) end)
Thanks :)