local rs = game:GetService("ReplicatedStorage")
local Update = rs:WaitForChild("UpdateGui")
local WinUpdater = rs:WaitForChild("WinsUpdater")
local DataStoreService = game:GetService("DataStoreService")
local DataStore1 = DataStoreService:GetDataStore("DataStore1")
local function ClientFire(wins)
print("super happy")
Update:FireAllClients(wins)
end
local function onPlayerJoin(player)
local wins = Instance.new("IntValue")
wins.Name = "wins"
wins.Value = 0
wins.Parent = player
local ID = player.UserId
local data
local s, em = pcall(function()
return DataStore1:GetAsync(ID, data)
end)
if s then
print("got data!")
wins.Value = data
else
warn(em)
end
ClientFire(wins.Value)
end
game.Players.PlayerRemoving:Connect(function(player)
local ID = "Player_"..player.UserId
local data = player.wins.Value
local s, em = pcall(function()
DataStore1:SetAsync(ID,data)
end)
if s then
print("saved!" .. data)
else
print("sad")
warn(em)
end
end)
game.Players.PlayerAdded:Connect(onPlayerJoin)
WinUpdater.Event:Connect(function(tp, plr)
print("very happy")
local wins = plr:WaitForChild("wins")
if tp == 1 then
wins.Value = wins.Value + 2
else if tp == 2 then
wins.Value = wins.Value + 1
end
end
ClientFire(wins)
end)
This is the script. Every time I run it, it says it saves the wins, prints the amount saved, and says it got the data but still never actually saves the wins. Can someone please help me?

2 comments
Where would I put this code into my script? I'm having some trouble, sorry if it's a stupid question.
Here: https://pastebin.com/pgbPuWfP. This should solve all the issues with your code.