Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Remotes = ReplicatedStorage.Remotes
- local DailyRewardsConfig = require(ReplicatedStorage.DailyRewards)
- local function ClaimReward(Player: Player, Day: number)
- local DailyRewardStat = Player:FindFirstChild("DailyReward")
- local LastCollectTimeStat = Player:FindFirstChild("LastCollectTime")
- local Leaderstats = Player:FindFirstChild("leaderstats")
- local CurrentDay = DailyRewardStat.Value
- local LastCollectTime = LastCollectTimeStat.Value
- local CurrentTime = os.time()
- if CurrentDay ~= Day then return end
- if LastCollectTime ~= 0 and CurrentTime - LastCollectTime < 24 * 60 * 60 then return end
- local Reward = DailyRewardsConfig[tostring(Day)]
- if not Reward then return end
- local RewardStat = Leaderstats:FindFirstChild(Reward.Type)
- if RewardStat and RewardStat:IsA("NumberValue") then
- RewardStat.Value += Reward.Amount
- print("Reward Claimed!")
- end
- LastCollectTimeStat.Value = CurrentTime
- DailyRewardStat.Value = CurrentDay + 1
- Remotes.ClaimDailyReward:FireClient(Player)
- end
- Remotes.ClaimDailyReward.OnServerEvent:Connect(ClaimReward)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement