this is my scripts so far..
.~~~~~~~~~~~~~~~~~ local Cash = game.Players. --what goes here again? local CashPart = script.Parent local count = game.Workspace.Counter local function onPartTouch (otherPart) if (count)then Cash = Cash + 10 end
end
1 | and then there is this script... |
1 | local currencyName = "Cash" |
local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore")
game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder") folder.Name= "leaderstats" folder.Parent = player
01 | local currency = Instance.new( "IntValue" ) |
02 | currency.Name = currencyName |
03 | currency.Parent = folder |
04 |
05 | local ID = currencyName.. "-" .. player.UserId |
06 | local savedData = nil |
07 |
08 | pcall ( function () |
09 | savedData = DataStore: GetAsysc(ID) |
10 | end ) |
end) ~~~~~~~~~~~~~~~~~
i'm trying to make the Currency go up by 10 when the Clone Part touches the Counter. Please Help Me!
i see your putting datastore in for data store:
01 | local DSService = game:GetService( 'DataStoreService' ):GetDataStore( 'data' ) |
02 | game.Players.PlayerAdded:connect( function (plr) |
03 | -- Define variables |
04 | local uniquekey = 'id-' ..plr.userId |
05 | local leaderstats = Instance.new( 'IntValue' , plr) |
06 | local savevalue = Instance.new( 'IntValue' ) |
07 | leaderstats.Name = 'leaderstats' |
08 | savevalue.Parent = leaderstats |
09 | savevalue.Name = 'Cash' |
10 |
11 | -- GetAsync |
12 | local GetSaved = DSService:GetAsync(uniquekey) |
13 | if GetSaved then |
14 | savevalue.Value = GetSaved [ 1 ] |
15 | else |
01 | for cash increase: |
02 |
03 | amount = 2 -- This variable is the amount of cash we will give each time. |
04 | timedelay = 2 -- This variable is the amount of seconds inbetween each time the cash is rewarded |
05 | currencyname = "Cash" -- This is the name of your Currency |
06 |
07 | while true do |
08 | wait(timedelay) |
09 | for i,v in pairs (game.Players:GetPlayers()) do |
10 | if v:FindFirstChild( "leaderstats" ) and v then |
11 | v.leaderstats [ currencyname ] .Value = v.leaderstats [ currencyname ] .Value + amount |
12 | end |
13 | end |
end