local Data = game:GetService("DataStoreService")
local TouchData = Data:GetDataStore("TouchData")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Touches = Instance.new("IntValue",leaderstats)
Touches.Name = "Touches"
local SavedData = TouchData:GetAsync(tostring(player.UserId))
if SavedData == nil then
player.leaderstats.Touches.Value = 0
else
player.leaderstats.Touches.Value = SavedData
end
end)
game.Players.PlayerRemoving:Connect(function(player)
TouchData:SetAsync(tostring(player.UserId), player:FindFirstChild("leaderstats"):WaitForChild("Touches").Value)
end)
Why does it not show my leaderstats when I join?