local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("sAvePLR_Dataa")
game.Players.PlayerAdded:connect(function(plr)
local coins = Instance.new("IntValue", plr)
coins.Name = "Coins"
local rubys = Instance.new("IntValue", plr)
rubys.Name = "Rubys"
local function getData()
local getSave = ds1:GetAsync(plr.UserId)
if getSave then
coins.Value = getSave[1]
rubys.Value = getSave[2]
else
local savetable = {
coins.Value,
rubys.Value,
}
ds1:SetAsync(plr.UserId, savetable)
end
end
local pass = false
repeat
local pass, msg = pcall(getData)
wait()
until
pass
game.Players.PlayerRemoving:connect(function(plr)
local savetable = {
coins.Value,
rubys.Value,
}
ds1:SetAsync(plr.UserId, savetable)
end)
game:BindToClose(function()
local savetable = {
coins.Value,
rubys.Value,
}
ds1:SetAsync(plr.UserId, savetable)
end)
end)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("this game has shutdown")
end
end
wait(5)
end)
This script doesn't save data when I test it in studio, this script disappears from ServerScriptService is there any reason why this script disappears and doesn't save players data?
If you know the answer, please let me know. I'm very confused about why this isn't working.

1 comment
There weren’t really any errors and I’m new to scripting so I’m not sure how I would change my script to match what you are saying