Help with Rewards system thats VERY broken

Are you 100% sure you deleted your datas?

yea im pretty sure about it cuz i double checked it with datastore editor

The script is working fine for me.
image
image

here is a pic of my gui
image

and my prize list module

local module = {}
module.rewards = {
	["1"] = 100,
	["2"] = 200,
	["3"] = 300,	
	["4"] = 400,
	["5"] = 500,
	["6"] = 600,
	["7"] = 700,
}

return module

Open the command line in Roblox Studio and type the following:

local DataStoreService = game:GetService("DataStoreService"):GetDataStore("DailyRewardService"):RemoveAsync(1861882725)

This might fix the issue.

ok ill do that right now char limit

i removed it and tried it worked the first time and after i claimed it and i rejoined that error popped up again

About it, using a module is completely useless. Looks like you’re adding 100 to all rewards after each day. Instead, you could just do:

local Reward = days * 100

well yeah but i might change it in future with different values and such

Interesting… :thinking: Are you getting the exact same error?

yeah exact same error in exact line

ServerScriptService.DailyReward:13: attempt to perform arithmetic (sub) on number and nil 

Could you please show me the edited version of the script?

Server
game.Players.PlayerAdded:Connect(function(Player)

	local DataStoreService = game:GetService("DataStoreService"):GetDataStore("abc") -- Define the Datastore service and define our datastore name

	local LastLogin -- Define a variable that we will use later.

	pcall(function()

		LastLogin = DataStoreService:GetAsync(Player.UserId) -- Check if the player joined already in the past 24 hours

	end)

	if LastLogin and (os.time() - LastLogin.Unix >= 86400) then

		-- os.time() returns how many seconds have passed since the Unix epoch (1 January 1970, 00:00:00)
		-- 86400 is the number of seconds in one day
		local Days = LastLogin.Days + 1
		DataStoreService:SetAsync(Player.UserId, {
			Unix = os.time(),
			Days
		}) -- We update the player datastoreto the current Unix epoch

		game.ReplicatedStorage.RewardSystem.ShowGui:FireClient(Player, Days) -- We fire an event ()

	elseif not LastLogin then -- If the player never joined the game before
		local Days = 1
		DataStoreService:SetAsync(Player.UserId, {
			Unix = os.time(),
			Days
		}) -- We update the player datastoreto the current Unix epoch

		game.ReplicatedStorage.RewardSystem.ShowGui:FireClient(Player, Days) -- We fire an event ()
	end
end)

game.ReplicatedStorage.RewardSystem.GiveMoney.OnServerEvent:Connect(function(plr,cash)
	plr.leaderstats.Cash.Value +=1 
end)
local
local rewardsdata = require(game.ReplicatedStorage.RewardConfig)
local cash
game.ReplicatedStorage.RewardSystem.ShowGui.OnClientEvent:Connect(function(days)
	print(days)
	print(typeof(days))
	for i,v in pairs(script.Parent:GetChildren()) do
		if v:IsA("Frame") then
			for di = 1, days, 1 do
				if v.Name == "Reward"..di then
					v.BackgroundColor3 = Color3.fromRGB(43, 192, 255)
				else
					v.BackgroundColor3 = Color3.fromRGB(86,86,86)
				end
			end
		end
	end
	for i,v in pairs(rewardsdata.rewards) do
		if tostring(days) == i then
			cash = v
		end
	end
	script.Parent.Parent:TweenPosition(UDim2.new(0.5,0,0.5,0), "Out", "Bounce",1 )
end)

script.Parent.Parent.Cashout.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RewardSystem.GiveMoney:FireServer(cash)
	script.Parent.Parent:TweenPosition(UDim2.new(3,0,0.5,0), "Out", "Bounce",1 )
end)
module
local module = {}
module.rewards = {
	["1"] = 100,
	["2"] = 200,
	["3"] = 300,	
	["4"] = 400,
	["5"] = 500,
	["6"] = 600,
	["7"] = 700,
}

return module

@Arlenox


I see you made a variable called Days. To fix the issues, just change lines DataStoreService:SetAsync(Player.UserId, {... to:

DataStoreService:SetAsync(Player.UserId, {
	Unix = os.time(),
	Days = Days
})

I understand but it doesn’t matter. The script will still work.

oh im still getting the same error

it seems like the LastLogin.Unix value is nil when i print it

thx for all the help i somehow fixed it

game.Players.PlayerAdded:Connect(function(Player)

	local DataStoreService = game:GetService("DataStoreService"):GetDataStore("abc") -- Define the Datastore service and define our datastore name

	local LastLogin -- Define a variable that we will use later.

	pcall(function()

		LastLogin = DataStoreService:GetAsync(Player.UserId) -- Check if the player joined already in the past 24 hours

	end)
	if LastLogin and (os.time() - LastLogin.Unix >= 86400) then

		-- os.time() returns how many seconds have passed since the Unix epoch (1 January 1970, 00:00:00)
		-- 86400 is the number of seconds in one day
		local days = LastLogin.Days + 1
		DataStoreService:SetAsync(Player.UserId, {
			Unix = os.time(),
			Days = days
		}) -- We update the player datastoreto the current Unix epoch

		game.ReplicatedStorage.RewardSystem.ShowGui:FireClient(Player, days) -- We fire an event ()

	elseif not LastLogin then -- If the player never joined the game before
		local days = 1
		DataStoreService:SetAsync(Player.UserId, {
			Unix = os.time(),
			Days = days
		}) -- We update the player datastoreto the current Unix epoch

		game.ReplicatedStorage.RewardSystem.ShowGui:FireClient(Player, days) -- We fire an event ()
	else
		print("nothing")
	end
end)

game.ReplicatedStorage.RewardSystem.GiveMoney.OnServerEvent:Connect(function(plr,cash)
	plr.leaderstats.Cash.Value +=1 
end)

hey i found a problem where the days value go past 7 any ways to fix i know i can do:

if Days > 7 then
   Days = 1
end

but i dont know which part of script i have to put

Just do days * 100. :grinning_face_with_smiling_eyes: