local script:
script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.UpdateData:FireServer() end)
server script:
local DStoreService = game:GetService("DataStoreService") local CashStore = DStoreService:GetDataStore("Cash") game.ReplicatedStorage.UpdateData.OnServerEvent:Connect(function(plr) local MaxHealth = game.Workspace:WaitForChild("player.Name"):WaitForChild("Humanoid").MaxHealth local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value CashStore:SetAsync("plr_"..plr.UserId, CashValue, MaxHealth) end) game.Players.PlayerRemoving:Connect(function(plr) local MaxHealth = game.Workspace:WaitForChild("player.Name"):WaitForChild("Humanoid").MaxHealth local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value CashStore:GetAsync("plr_"..plr.UserId, CashValue, MaxHealth) end)
it wont save my progress
Try using the actual game and not Roblox Studio or in Game Settings on Security and turn on Studio Access to API Services
Change the MaxHealth variable to this
local Character = plr.Character or plr.CharacterAdded:Wait() local MaxHealth = Character:FindFirstChildWhichIsA("Humanoid").MaxHealth