Hello, Dear Pepole! I need help with DataStore, cause Of My Data not Storing Other Players Data, and i Need Help to Store it, I Hope i will Get a Answer!
Script in ServerScript Service:
--[[
2/2/21
RektwayYTB
DataStore/Leaderstats
--]]
local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("playerData")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Parent = leaderstats
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = playerData:GetAsync(player.UserId.."-points")
data = playerData:GetAsync(player.UserId.."-wins")
end)
if success then
points.Value = data
points.Value = data
else
print("Error while getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
playerData:SetAsync(player.UserId.."-points", player.leaderstats.Points.Value)
playerData:SetAsync(player.UserId.."-wins", player.leaderstats.Wins.Value)
end)
if success then
print("Data successfully saved!")
else
print("There was an error while saving the data")
warn(errormessage)
end
end)
If i did an Error Please also Answer!

1 comment
Thank You! Have happy new year