|
| 15 May 2015 05:59 PM |
local sc = script.Parent local gd = sc.MainFrame.GUIData
game.Players.PlayerAdded:connect(function(player) if math.floor(os.time()) >= t1 then if t1 - t2 >= 1 then gd.Cash.Value = gd.Cash.Value + 250 end end end)
|
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 06:04 PM |
local t1 = what I have no clue honestly? |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 06:28 PM |
Heres a snippet of my code for the daily rewards in my game. Use if if you can.
local lastOSTime = os.time() --This value should be saved, then loaded when the player joins back to allow them to join back after 24 hours and get a reward.
if lastOSTime and (os.difftime(os.time(), lastOSTime.Value)) >= 86400 then lastOSTime = os.time() print(Player.Name .. " has recieved a daily bonus!") else lastOSTime = round((86400 - os.difftime(os.time(), lastOSTime.Value))/3600, 2) print(Player.Name .. " has not recieved a daily bonus, not enough time has passed!") end |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 06:43 PM |
| what about round its not accounted for? what should it be accounted for? |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 07:08 PM |
Whoops, here's the round function.
function round(number, toDigits) number = math.floor(number*10^toDigits+.5)/(10^toDigits) return number end |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 08:12 PM |
| 19:12:06.263 - Players.Player.PlayerGui.Gameplay.GUIScript:255: attempt to index local 'lastOSTime' (a number value) |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 08:37 PM |
I don't understand your coding, you have t1 and t2 but you don't have what they =?
|
|
|
| Report Abuse |
|
|
|
| 15 May 2015 08:45 PM |
local bonusDataStore = game:GetService("DataStoreService"):GetDataStore("BonusDataStore") local timebetweenBonus = 24 -- How much time(in hours) a player must wait in-between bonuses.
-- This function is fired when the player earns an award. -- So change it to do what you want when a player -- Earns an award local function giveBonus(player) local stats = player:WaitForChild("leaderstats") local money = stats:WaitForChild("Money") money.Value = money.Value + 14151418418490148901840124812048129089012 end
local function playerAdded(player) local lastJoinTime = bonusDataStore:GetAsync(player.userId) if lastJoinTime and (os.time() - lastJoinTime) > (60 * 60) * timebetweenBonus then giveBonus(player) bonusDataStore:SetAsync(player.userId, os.time()) elseif lastJoinTime == nil then bonusDataStore:SetAsync(player.userId, os.time()) end end
game.Players.PlayerAdded:connect(playerAdded) |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 01:57 AM |
| Would it be possible to do a countdown clock? HH:MM:SS |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 16 May 2015 08:49 AM |
preview. c9. io/lunate/skyewashere/Time.mod.lua
Contains code for formatting seconds to easy to use data. Works with os.time and tick, including differences. |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 10:43 AM |
| Didn't understand a word you said. |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 May 2015 12:20 PM |
| Ok so the daily bonus is working. I just need a countdown timer with it. Any help? |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 16 May 2015 02:17 PM |
It's a url you silly cheeseball.
Copy paste the whole thing (From preview to .lua) into your url bar and look. |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 02:28 PM |
| eLunate, you're checking to see if a year is a leap year incorrectly. |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 02:31 PM |
| Imagine if some poor soul is incorrectly told the year 2100 is a leep year 85 years in the future. How would you live with yourself? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 16 May 2015 02:32 PM |
| If you're about to make the smart comment about %100 and %400 I don't want to hear it. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 16 May 2015 02:33 PM |
You damned well did too.
I knew that was coming from the moment I made the script. Thanks calenders. |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 02:34 PM |
| I don't see why you don't check for that, though. |
|
|
| Report Abuse |
|
|