Xenon Drift Daily Reward Streak v4
UTC-safe daily streak tracker for Xenon Drift.
| 1 | local Players = game:GetService("Players") |
| 2 | local DataStoreService = game:GetService("DataStoreService") |
| 3 | local store = DataStoreService:GetDataStore("DailyStreakV3") |
| 4 | |
| 5 | local function todayUtc() |
| 6 | local now = DateTime.now():ToUniversalTime() |
| 7 | return string.format("%d-%02d-%02d", now.Year, now.Month, now.Day) |
| 8 | end |
| 9 | |
| 10 | Players.PlayerAdded:Connect(function(player) |
| 11 | local key = "streak:" .. player.UserId |
| 12 | local ok, data = pcall(function() |
| 13 | return store:GetAsync(key) |
| 14 | end) |
| 15 | local last = data and data.last or nil |
| 16 | local streak = data and data.streak or 0 |
| 17 | local today = todayUtc() |
| 18 | if last == today then |
| 19 | -- already claimed |
| 20 | elseif last then |
| 21 | local lastDate = DateTime.fromIsoDate(last) |
| 22 | local diff = DateTime.now():ToUniversalTime().UnixTimestamp - lastDate.UnixTimestamp |
| 23 | if diff < 60 * 60 * 24 * 2 then |
| 24 | streak += 1 |
| 25 | else |
| 26 | streak = 1 |
| 27 | end |
| 28 | else |
| 29 | streak = 1 |
| 30 | end |
| 31 | store:SetAsync(key, { last = today, streak = streak }) |
| 32 | player:SetAttribute("DailyStreak", streak) |
| 33 | end) |
How It Works
Technical Breakdown
Daily Reward Streak for Xenon Drift is built as a production-style baseline instead of a toy snippet. The script focuses on clear separation of setup, runtime logic, and extension points so teams can scale it without rewriting everything later. It is intentionally opinionated around Roblox services, attributes, and predictable event flow to reduce debugging time during live updates. You can drop this into an active game, validate behavior quickly, then evolve constants, data keys, and UX hooks around your design goals. In short, this gives you a stable starting architecture for daily reward streak while keeping enough flexibility for custom systems.
How To Use
Step-by-Step Guide
Placement: Put the script in ServerScriptService.
Required objects: Create all folders/parts/instances referenced by WaitForChild calls before testing.
Configure values: Confirm UTC date logic and hook reward grant flow from your claim UI to this streak state
Attribute contract: Verify attribute names and value types exactly match what the script expects.
Studio test pass: Run Play Solo and trigger the feature 3-5 times to confirm baseline behavior.
Multiplayer test pass: Start a local server with at least 2 players to catch replication and ownership edge cases.
Authority check: This script is server-oriented, so keep trust-sensitive logic on the server.
Failure handling: Add guards/logging for timezone assumptions and duplicate claim events creating incorrect streak increments.
Performance hardening: Store claim metadata and process reward grants idempotently with UpdateAsync.
Ship checklist: Add telemetry counters, tune UX feedback, and document your final constants in a team note.
Pro Tips
5 Tips from the Pros
FAQ
7 Common Questions
Is this daily reward streak script server or client?
Server authority is recommended for this implementation. Keep game-state truth on the server and only use client scripts for presentation, camera, or local UX polish.
Why does it not work immediately after paste?
Most issues come from missing folders, tags, or attributes. Check placement first, then confirm names and casing exactly match the script expectations.
Can I rename keys, tags, or folders?
Yes, but rename them in one pass and keep references synchronized. Partial renames are the most common reason scripts silently fail.
How do I make this production ready?
Add retries, add telemetry, guard nil paths, and run multiplayer tests with realistic latency. Also wrap any DataStore or network operation in robust error handling.
What should I tune first for balance?
Tune visible gameplay constants first (timings, damage, cooldowns, ranges) and only then tune deep infrastructure values. This gives faster player-facing iteration.
Will this scale to bigger maps or more players?
Yes if you profile and optimize hotspots early. Focus on event frequency, allocations in loops, and expensive service calls inside frequent callbacks.
What is the main implementation risk?
timezone assumptions and duplicate claim events creating incorrect streak increments
