Help with playtime gift rewards

Hey guys, I am trying to make a playtime gift rewards system that:

#1 Is not cheatable, so no countdowns on the client
#2 Updates on the client without having to send an event every second from a server loop

I am assuming I have to keep countdowns / timer information in the server and then a secondary one in the client for the GUI and then check on the server if both timers are the same once the player claims the reward to make sure it was not exploited?

I am just not sure how to make the timers on the server

I got this so far:

local function SetupRewards(times)
	-- Loop through the rewards GUI and set the countdown text
	for i, v in pairs(oContainer:GetChildren()) do
		if v:IsA("Frame") then
			local countdownText = v.Countdown
           -- set the text based on our server table for each reward and format
			countdownText.Text =  convertToHMS(times[v.LayoutOrder]*60) 
local rewardTimes ={
	1,	5,	10,	...

-- Im assuming I keep track of all player time here?
local playerRewardsCountdowns = {}

	--Start a timer for each here?
	table.insert(playerRewardsCountdowns, plr)
	reSetUpPlaytimeRewards:FireClient(plr, rewardTimes)	


Any help is super mega appreciated, thanks in advance!

Iā€™v made such a thing in the past for 2 of my games.
Insert a value in the player. For Every second the player is in the game,
increment the value by +1.

Now, on the client, you can simply use the logic:

local GiftClaimTime=(60*5) -- 5 Minutes
local TimePassed=Player.CurrentSession.Value

local TimeLeft=(GiftClaimTime-TimePassed)
if TimeLeft<=0 then
    -- Gift is ready to be claimed
    -- Update the text on the gift gui, gift not claimable yet.

You can wrap this in a loop, which updates the text on the gift every second.
As for the ā€œsecurityā€ part, counting on the client should not be an issue.

This is because every time the player actually claims the gift,
you can fire a remote to the server. Now, check on the server if the appropriate time has passed, and if the gift is actually claimable. (Use the same logic for counting that we used on the client, on the server)

1 Like

Awesome man adapted it to my code and to all gifts, set the button and the server response and it works perfectly. thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.