Hello, so I copied my datastore from AlvinBlox, and keep getting this error: 14:48:33.711 ServerScriptService.DataAndJoined:17: attempt to index nil with 'UserId' - Server - DataAndJoined:23
Code:
local DataStore = game:GetService("DataStoreService")
local FlowerManger = DataStore:GetDataStore("flrs")
local PlyrServ = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = player
local flrs = Instance.new("IntValue")
flrs.Name = "Flowers"
flrs.Value = 0
flrs.Parent = ls
local data
local success,errormessage = pcall(function(player)
data = FlowerManger:GetAsync(player.UserId.."-Flowers") --Where error occurs (not in testing)
end)
if success then
flrs.Value = data
print("Loaded In Data")
else
warn(errormessage)
print("Failed To Load Data")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success,errormessage = pcall(function()
FlowerManger:SetAsync(player.UserId.."-Flowers",player.leaderstats.Flowers.Value)
end)
if success then
print("Data Success")
else
print("Data Failed")
warn(errormessage)
end
end)
Very sorry if there is a lack of information. Please tell me so.