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
and then there is this script...
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
local currency = Instance.new("IntValue") currency.Name = currencyName currency.Parent = folder local ID = currencyName.."-".. player.UserId local savedData = nil pcall (function() savedData = DataStore: GetAsysc(ID) 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:
local DSService = game:GetService('DataStoreService'):GetDataStore('data') game.Players.PlayerAdded:connect(function(plr) -- Define variables local uniquekey = 'id-'..plr.userId local leaderstats = Instance.new('IntValue', plr) local savevalue = Instance.new('IntValue') leaderstats.Name = 'leaderstats' savevalue.Parent = leaderstats savevalue.Name = 'Cash' -- GetAsync local GetSaved = DSService:GetAsync(uniquekey) if GetSaved then savevalue.Value = GetSaved[1] else local NumbersForSaving = {savevalue.Value} DSService:SetAsync(uniquekey, NumbersForSaving) end end) game.Players.PlayerRemoving:connect(function(plr) local uniquekey = 'id-'..plr.userId local Savetable = {plr.leaderstats.Cash.Value} DSService:SetAsync(uniquekey, Savetable) end)
for cash increase: amount = 2 -- This variable is the amount of cash we will give each time. timedelay = 2 -- This variable is the amount of seconds inbetween each time the cash is rewarded currencyname = "Cash" -- This is the name of your Currency while true do wait(timedelay) for i,v in pairs(game.Players:GetPlayers()) do if v:FindFirstChild("leaderstats") and v then v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount end end
end