Hi,
It’s not saving. What am I doing wrong?
local dataStoreService = game:GetService("DataStoreService")
local ds = dataStoreService:GetDataStore("DataStoreTest")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local touches = Instance.new("IntValue")
touches.Name = "Touches"
touches.Parent = leaderstats
local touchesData, rebrithsData
local success, errormessage = pcall(function()
touchesData = ds:GetAsync("touches-"..plr.UserId)
end)
if success then
touches.Value = touchesData
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
ds:SetAsync("touches-"..plr.UserId, plr.leaderstats.touches.Value)
end)
end)