I have a daily login reward system, and it works mostly. Come back every 24 hours you get your reward. However, my goal was to have it be a streak, thus returning 4 days in a row would get you the 4th award in StreakAwards. However, it’s not working ![]()
At the moment, what’s happening is if you play, get the first reward. Come back a week later (having not played in a few days) you get the second reward? Not sure what else to do
local StreakAwards = {100, 250, 500, 750, 1000}
local function giveDailyReward(player, streak)
local Award = StreakAwards[streak]
if not Award then
Award = StreakAwards[#StreakAwards]
end
if GamepassCheck(player, 'Premium') then
Award = Award * 2
end
UpdateCoins(player, Award, false)
DailyReward:FireClient(player, streak)
local Data = {}
Data.Streak = streak
Data.LastLogin = os.time()
RewardDataStore:SetAsync(player.UserId, Data)
end
function RewardService:SetUp(player)
player.CharacterAdded:Wait()
local LoginData = RewardDataStore:GetAsync(player.UserId)
local Streak
if LoginData then
local Seconds = os.time() - LoginData.LastLogin
local Minutes = Seconds / 60
local Hours = Minutes / 60
if Hours >= 24 then
Streak = LoginData.Streak
if Streak >= 5 then
Streak = 1
else
Streak = Streak + 1
end
giveDailyReward(player, Streak)
end
else
Streak = 1
giveDailyReward(player, Streak)
end
end