Is this daily reward script good?

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
			enabled = true
			dailyrewardtaken = false

game.Workspace.Map["Treasure Chest By StarModelX"].DailyReward.Touched:Connect(DailyReward)

I wouldn’t call it safe, an exploiter can easily spoof the Touched event every 4 seconds to get points.

1 Like

But it will work right? (30 char)

Yeah I don’t see any reason that would cause it to not work.

1 Like

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.

1 Like

Isn’t that what a daily reward script does?

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 ("!*t").yday == YesterdaysYDay + 1) or ("!*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.