Still have questions? Join our Discord server and get real time help.
1

# My Daily Reward System return a table. How to get the countdown?

Asked by 10 months ago
Edited 10 months ago

I posted this not long time ago, and i received this script right here. I edited him a little bit for my use. But now, i have some questions about it. I'd like to create a UI with the amount of time before the reward. So i tried to send back the value of the PlayerData to get the time, but since she send me this in the output.

function: 16E5BAC4

--< Services
local PlayerService = game:GetService('Players')
local DataStoreService = game:GetService('DataStoreService')

--< Variables
local DailyRewards = DataStoreService:GetDataStore('dailyRewards')

local RewardTime = 24 -- One day
local RewardAmmount = 50 -- They get 50 cash each day

local SessionData = {}

--< Event
local ls = Instance.new('Folder')
ls.Parent = Player

SessionData[Player] = {}
SessionData[Player]['Cash'] = 100

local Cash = Instance.new('IntValue', ls)
Cash.Name = 'Cash'
Cash.Value = SessionData[Player]['Cash']

local PlayerData = nil

pcall(function() -- No errors pls
PlayerData = DailyRewards:GetAsync('player_' .. Player.UserId)
end)

if PlayerData then
if ((os.time() - PlayerData) / (60 * 60)) >= RewardTime then
Cash.Value = PlayerData + RewardAmmount
DailyRewards:SetAsync(Player.UserId, os.time())
else
Cash.Value = PlayerData
end
else
DailyRewards:SetAsync(Player.UserId, os.time())
end
end)

0
os.time() TheRevealerYT 153 — 10mo
0
dude its easy just put the vector7 in the script and let the time center run for a while ! BlackCheap 14 — 9mo
0
Vector7? This is not exist (Vector2, Vector3) NiniBlackJackQc 593 — 9mo

0
Answered by 10 months ago

idk about your code but here's what you should do

local DataStoreService = game:GetService('DataStoreService')
local DailyRewards = DataStoreService:GetDataStore('dailyRewards')