Is this daily reward script safe? or can exploiters exploit it? and will it work in-game?
The code
enabled = true
local dailyrewardtaken = false
function DailyReward (hit)
humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid ~= nil and enabled == true then
if not dailyrewardtaken then
enabled = false
player = game.Players:GetPlayerFromCharacter(hit.Parent)
points = player.leaderstats.Points
points.Value = points.Value + 20
dailyrewardtaken = true
wait(4)
enabled = true
dailyrewardtaken = false
end
end
end
game.Workspace.Map["Treasure Chest By StarModelX"].DailyReward.Touched:Connect(DailyReward)
Given that the server itself never does a true check on dailyrewardtaken, nor does it even semantically represent dailyrewardtaken, it currently will pay out the daily reward once every four seconds.
In its current form, this is not a daily reward script. It’s just a script that increment’s a player’s points by 20 every 4 seconds if they move along the part.
Well, no. If it’s a daily reward script, it should award points every 86,400 seconds (24 hours), when Player.AccountAge == YesterdaysAge + 1, or when (os.date("!*t").yday == YesterdaysYDay + 1) or (os.date("!*t").yday == 1 and (YesterdaysYDay == 365 or YesterdaysYDay == 366)) (you can always store the year when they last played and check if the previous year was a leap year, when you’re doing a check on 1st January, for more accuracy on this).
You need to be storing one of those variables every day and checking it the next time they play, otherwise it’s no different to a classic tycoon money giver.