of     1   

RickGrimes97
#220043348Thursday, June 29, 2017 6:04 PM GMT

So to start, I'm now trying to learn how your own virtual currency works in a game, I have found the forum to help over the past few weeks now, so i would like to just start by asking if anyone knows how to make a screengui button, with a one second debounce that starts off with 0, and every time you click it, it adds 1 to the screengui, and lets say i click it 20 times and leave the game, when i join back it should show 20, click another 20 times and leave, come back, it shows 40 for my user only. I'm really trying to learn how this works, anyone that can write a script explaining how this can be achieved will really help a lot Thank you
Milenveliki
#220045932Thursday, June 29, 2017 6:44 PM GMT

local m=Instance.new("Message",workspace) local DS=game:GetService"DataStoreService":GetDataStore"buttonlolz1" local Players=game:GetService"Players" Players.PlayerAdded:Connect(function(player) local textbutton = Instance.new("TextButton",Instance.new("ScreenGui",player:WaitForChild("PlayerGui",1.5))) if textbutton then textbutton.Text=DS:GetAsync(player.Name..'lolz')or '0' textbutton.Size=UDim2.new(0,150,0,150) local save textbutton.MouseButton1Click:Connect(function() textbutton.Text=tonumber(textbutton.Text)+1 if not save then save=true delay(4,function() DS:SetAsync(player.Name..'lolz',textbutton.Text) m.Text='data saved...'wait(1.5)m.Text='' save=false end) end end) end end)
RickGrimes97
#220047516Thursday, June 29, 2017 7:09 PM GMT

so what type of script does this go in to? a local or regular, and where do i place the script, i really appreciate it btw
Milenveliki
#220047983Thursday, June 29, 2017 7:16 PM GMT

regular script in Workspace/ServerScriptService
Milenveliki
#220048396Thursday, June 29, 2017 7:22 PM GMT

btw it won't save if you r playing in studio
RickGrimes97
#220049229Thursday, June 29, 2017 7:37 PM GMT

ok, it works perfectly, thank you

    of     1