this script doesnt save and i enable api services can any one help me
local DataStoreService = game:GetService("DataStoreService")
local DataStore5 = DataStoreService:GetDataStore("DataStore5")
game.Players.PlayerAdded:Connect(function(player)
wait(0.1)
local Jump = Instance.new("IntValue")
Jump.Name = "Jump"
Jump.Parent = player.leaderstats
local playerUserId = "Player_"..player.UserId
local success, errormessage = pcall(function()
data = DataStore5:GetAsync(playerUserId)
end)
if success then
Jump.Value = data
-- set our data = to current cash
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local Data1 = player.leaderstats.Jump.Value
local success, errormessage = pcall(function()
DataStore5:SetAsync(playerUserId,Data1)
end)
if success then
print("DataSaved")
else
print("ThereWasAnError")
warn(errormessage)
end
print("done")
end)

1 comment
im not sure but u should combine the script that makes the leaderstats