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

Making A Clicker Game And Have This I Cant Figure Out How To Make Work?

Asked by 6 years ago
Edited 6 years ago

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
0
please use a code block User#19524 175 — 6y
0
Please use more, ideally the whole script ABK2017 406 — 6y
0
ive never used this before so i dont know how to xxethanb1xx 14 — 6y
0
Click on the blue Lua code block and paste the code in between the tildes User#19524 175 — 6y
View all comments (2 more)
0
there ive fixed it xxethanb1xx 14 — 6y
0
So basically, you need a DataStore? I'm kinda confused by your question but if you need a DataStore I can help you out. Michael_TheCreator 166 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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)
Ad

Answer this question