Output not showing anything?

So I am working on a daily rewards system and I have print() statements checking if the code is working. The problem is, the print() statements don’t show up in the output.

server script:

--// Datastore
local Ds = game:GetService("DataStoreService"):GetDataStore("DailyRewardSystem#T3")

--// Variabbles
local premiumRemote = game.ReplicatedStorage.RemoteEvents.PremiumDailyReward
local normalRemote = game.ReplicatedStorage.RemoteEvents.NormalDailyReward

--// Streak Rewards
local StreakRewards = {1500, 5000, 12500, 25000, 40000, 75000, 200000}
local PremiumRewards = {10, 25, 45, 75, 110, 155, 250} -- in crystals

game.Players.PlayerAdded:Connect(function(plr)
	pcall(function()
		wait(5.1)
		local Data = nil
		Data = Ds:GetAsync(plr.UserId)
		
		local Multiplier = plr.Gamepasses.VIP:WaitForChild("Daily Reward Multiplier")
		local Premium = plr.Gamepasses:FindFirstChild("Premium Daily Rewards")
		
		if Data ~= nil then
			local Seconds = os.time() - Data.LastLogin
			local Minutes = Seconds/60
			local Hours = Minutes/60
			print(Hours)
			if Hours <= 0.01 then
				local Streak = Data.Streak
				if Streak < 7 then
					if Premium.Value ~= true then
						Streak = Streak + 1
						print(Streak)
						local Reward = StreakRewards[Streak]
						local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
						cash.Value = cash.Value + Reward * Multiplier.Value
						
						local day = "Day"..Streak
						normalRemote:FireClient(plr, day)
					elseif Premium.Value == true then
						Streak = Streak + 1
						print(Streak)
						local Reward = PremiumRewards[Streak]
						local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
						local crystals = plr.leaderstats.Crystals
						
						crystals.Value = crystals.Value + Reward * Multiplier.Value
						cash.Value = cash.Value + ((Reward * 1200) * Multiplier.Value)
						
						local day = "Day"..Streak
						premiumRemote:FireClient(plr, day)
					end
					
				elseif Streak == 7 then
					if Premium.Value ~= true then
						Streak = 1
						print(Streak)
						local Reward = StreakRewards[Streak]
						local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
						cash.Value = cash.Value + Reward * Multiplier.Value
						
						local day = "Day"..Streak
						normalRemote:FireClient(plr, day)
					elseif Premium.Value == true then
						Streak = 1
						print(Streak)
						local Reward = PremiumRewards[Streak]
						local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
						local crystals = plr.leaderstats.Crystals
						
						crystals.Value = crystals.Value + Reward * Multiplier.Value
						cash.Value = cash.Value + ((Reward * 1000) * Multiplier.Value)
						
						local day = "Day"..Streak
						premiumRemote:FireClient(plr, day)
					end
				end
				
				local NewData = {}
				NewData.Streak = Streak
				NewData.LastLogin = os.time()
				Ds:SetAsync(plr.UserId, NewData)
			elseif Hours > 24 then
				local NewData = {}
				NewData.Streak = 1
				NewData.LastLogin = os.time()
				
				if Premium.Value ~= true then
					local Reward = StreakRewards[NewData.Streak]
					local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
					cash.Value = cash.Value + Reward * Multiplier.Value
					
					local day = "Day"..NewData.Streak
					normalRemote:FireClient(plr, day)
				elseif Premium.Value == true then
					local Reward = PremiumRewards[NewData.Streak]
					local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
					local crystals = plr.leaderstats.Crystals
						
					crystals.Value = crystals.Value + Reward * Multiplier.Value
					cash.Value = cash.Value + ((Reward * 1200) * Multiplier.Value)
					
					local day = "Day"..NewData.Streak
					premiumRemote:FireClient(plr, day)
				end
				
				Ds:SetAsync(plr.UserId, NewData)
			end
		elseif Data == nil then
			local NewData = {}
			NewData.Streak = 1
			NewData.LastLogin = os.time()
			if Premium.Value ~= true then
				local Reward = StreakRewards[NewData.Streak]
				local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
				cash.Value = cash.Value + Reward * Multiplier.Value
				
				local day = "Day"..NewData.Streak
				normalRemote:FireClient(plr, day)
			elseif Premium.Value == true then
				local Reward = PremiumRewards[NewData.Streak]
				local cash = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
				local crystals = plr.leaderstats.Crystals
						
				crystals.Value = crystals.Value + Reward * Multiplier.Value
				cash.Value = cash.Value + ((Reward * 1200) * Multiplier.Value)
				
				local day = "Day"..NewData.Streak
				premiumRemote:FireClient(plr, day)
			end
		end
	end)
end)

local script:

game.ReplicatedStorage.RemoteEvents.NormalDailyReward.OnClientEvent:Connect(function(day)
	print(day)
	local checkMark = script.Parent.Checkmark
	
	script.Parent.Visible = true
	script.Parent.Parent.Exit.Visible = true
	checkMark.Parent = script.Parent:FindFirstChild(day)
	checkMark.Visible = true
end)

So

print(Streak)
-- And
print(day)

Doesn’t do anything.

Why is this happening???

Don’t wrap the entire function in a pcall. It suppresses errors that likely occur before those print statements and thus the output is blank. Only wrap the GetAsync() call in a pcall function. From there, your script should tell you what is erroring and why it won’t print. Also just a tip, don’t do if Value == true. You can just do if Value then
Same with if data == nil then. Just do if not data then
Once you fix the pcall wrapping, I’m sure you will see an easy error to fix. If not, let me know and I can help further.

Cheers

2 Likes