I know I will get thumbs downs for this, but I have spent weeks on it and haven't figured it out
Any help? I am clueless at this point
3/26/2014 Update
Here's the rough script I have so far, please comment on any errors or glitches as I continue to make the script.
local DataStore = game:GetService("DataStoreService"):GetDataStore("Time") game.Players.PlayerAdded:connect(function(player) wait(3) local label = player.PlayerGui.TimeLeft.Frame.TimeLeftLabel local ready = player.PlayerGui.TimeLeft.Frame.Ready.ReadyToVisit local key = "user_" .. player.userId --we want to give 50 points to users each time they visit DataStore:UpdateAsync(key, function(oldValue) local now = tick() local later = oldValue or 300 --oldValue might be nil local difference = math.abs(now - later) local left = 300 - difference if left < 0 then left = 0 end repeat label.Visible = true local now = tick() local later = oldValue or 300 --oldValue might be nil local difference = math.abs(now - later) local left = 300 - difference if left < 0 then left = 0 end label.Text = left wait(0.1) until left == 0 or ready.Value == true label.Visible = false ready.Value = true end) --DataStore End end) --player enter end
Record the time the player first joins. Each next time the player joins, check the time and see if it has been 12 hours.
local data=game:service("DataStoreService"):GetDataStore("Points") game.Players.PlayerAdded:connect(function(player) local time=player:LoadNumber("JoinTime") if time==0 then player:SaveNumber("JoinTime",os.time()) else local reps=math.floor((os.time()-time)/12/60/60) if reps<0 then data:IncrementAsync(player.Name,reps*200) player:SaveNumber("JoinTime",time+reps*12*60*60) wait(time-reps*12*60*60) player:SaveNumber("JoinTime",os.time()) data:IncrementAsync(player.Name,200) end end while wait(12*60*60)do player:SaveNumber("JoinTime",os.time()) data:IncrementAsync(player.Name,200) end end)
This stores players' points in datastore and their time playing in data persistence. It calculates the amount of time that has passed since they were last there and rounds it down to a multiple of 12 hours and multiplies that by 200 for the amount of points to be incremented. When they come back, their timer is not reset; it keeps the remaining time until the next 12 hours.