Answered by
8 years ago Edited 8 years ago
local DataStore = game:GetService("DataStoreService"):GetGlobalDataStore("TrustCurrency")
local Repeats = game:GetService("DataStoreService"):GetGlobalDataStore("BeenThere")
game.Players.PlayerAdded:connect(function(plr)
local inst = Instance.new("StringValue", plr)
inst.Name = "Repeat"
inst.Value = "No"
local bank = game.StarterGui.ScreenGui.Frame.Credits
local stats = Instance.new("IntValue", plr)
stats.Name = "leaderstats"
local credits = Instance.new("IntValue", stats)
credits.Name = "Credits"
credits.Value = 0
local key = "player-"..plr.userId
local savedCredits = DataStore:GetAsync(key)
local savedValue = Repeats:GetAsync(key)
if savedValue == "No" then
local creditcount = (credits.Value + 100)
DataStore:SetAsync(key, creditcount)
inst.Value = "Yes"
Repeats:SetAsync(key, inst.Value)
elseif savedValue == "Yes" then
credits.Value = savedCredits
print(savedValue)
end
end)