so im trying to make a clicker game where it saves the price of what your item is at but the datastore is too confusing for me ive looked on youtube but i dont understand it could someone please help also there are 2 scripts
this is the script thats for the item its a local script in a starter gui
button = game.StarterGui.Shop.Frame.ImageButton player = game.Players.LocalPlayer cost = game.ReplicatedStorage.StatFile.LocalPlayer.statnumbers.cost1.Value add = 1 button.MouseButton1Down:connect(function() if player.leaderstats.Money.Value >= cost then player.leaderstats.Money.Value = player.leaderstats.Money.Value - cost player.leaderstats.MPS.Value = player.leaderstats.MPS.Value + add cost = cost + 50 end end) while true do wait(0.01) script.Parent.Text = "Cost: "..cost end
So you need an easy to understand and use DataStore script to save your leaderboard? Worry not, got just the right tool for you, saves automatically the values and names!
Just put this in a SCRIPT in Workspace
game.Players.PlayerRemoving:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")--Player key local statstorage = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #statstorage do datastore:SetAsync(statstorage[i].Name, statstorage[i].Value) end end) game.Players.PlayerAdded:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats") player:WaitForChild("leaderstats") wait(1) local stats = player:FindFirstChild("leaderstats"):GetChildren() for i = 1, #stats do stats[i].Value = datastore:GetAsync(stats[i].Name) end end)