Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to Save Weights? (Weightlifting sim)

Asked by 4 years ago

Making a Weightlifting game and i have multiple weights u can buy but im also trying to make it so the weights also save so you dont lose the weights when you go back into the game but idk how to save the weights could anyone help and explain? Thanks!


local DataStore = game:GetService("DataStoreService") local PointsData = DataStore:GetOrderedDataStore("Points") game.Players.PlayerAdded:Connect(function(player) local points = PointsData:GetAsync(player.UserId) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" local pointsValue = Instance.new("IntValue",leaderstats) pointsValue.Value = points leaderstats.Parent = player pointsValue.Name = "Strength" end) game.Players.PlayerRemoving:Connect(function(player) local strength = player.leaderstats.Strength.Value PointsData:SetAsync(player.UserId, strength) print("Saved Data!") end) game.ReplicatedStorage.BuyItem.OnServerEvent:Connect(function(player,weight) if player.leaderstats.Strength.Value >= weight.Price.Value then player.leaderstats.Strength.Value = player.leaderstats.Strength.Value - weight.Price.Value local newWeight = weight:Clone() local oldWeight = player.Backpack:FindFirstChildOfClass("Tool")or player.Character:FindFirstChildOfClass("Tool") oldWeight:Destroy() newWeight.Parent = player.Backpack end end)

(thats strength that im saving currently but i also want to save weights along with it)

Answer this question