Hey there! My friend and I have been working on a game, and we ran into a little issue. We want to make a Daily Reward system, and it works fine. But the problem is that our 2x Gamepass doubles these points too. Is there a way to exclude the daily rewards from the gamepass? If so, please let me know.
Daily Reward Script:
local dss = game:GetService("DataStoreService")
local dailyRewardDS = dss:GetDataStore("DailyRewards")
local rewardsForStreak =
{
[1] = 5,
[2] = 15,
[3] = 25,
[4] = 50,
[5] = 75,
[6] = 100,
[7] = 150,
}
game.Players.PlayerAdded:Connect(function(plr)
local success, dailyRewardInfo = pcall(function()
return dailyRewardDS:GetAsync(plr.UserId .. "-DailyRewards")
end)
if type(dailyRewardInfo) ~= "table" then dailyRewardInfo = {nil, nil, nil} end
local cash = (plr.leaderstats.Points)
cash.Value = dailyRewardInfo[1] or 0
local lastOnline = dailyRewardInfo[2]
local currentTime = os.time()
local timeDifference
if lastOnline then
timeDifference = currentTime - lastOnline
end
if not timeDifference or timeDifference >= 24*60*60 then
local streak = dailyRewardInfo[3] or 1
local reward = rewardsForStreak[streak]
local dailyRewardGui = plr.PlayerGui:WaitForChild("DailyRewardGui")
local mainGui = dailyRewardGui:WaitForChild("MainGui")
local claimBtn = mainGui:WaitForChild("ClaimButton")
local rewardLabel = mainGui:WaitForChild("RewardLabel")
rewardLabel.Text = reward
dailyRewardGui.Enabled = true
claimBtn.MouseButton1Click:Connect(function()
cash.Value = cash.Value + reward
dailyRewardGui.Enabled = false
local streak = streak + 1
if streak > 7 then streak = 1 end
local success, errormsg = pcall(function()
dailyRewardDS:SetAsync(plr.UserId .. "-DailyRewards", {cash.Value, os.time(), streak})
end)
end)
elseif timeDifference then
wait((24*60*60) - timeDifference)
if game.Players:FindFirstChild(plr) then
local streak = dailyRewardInfo[3] or 1
local reward = rewardsForStreak[streak]
local dailyRewardGui = plr.PlayerGui:WaitForChild("DailyRewardGui")
local mainGui = dailyRewardGui:WaitForChild("MainGui")
local claimBtn = mainGui:WaitForChild("ClaimButton")
local rewardLabel = mainGui:WaitForChild("RewardLabel")
rewardLabel.Text = reward
dailyRewardGui.Enabled = true
claimBtn.MouseButton1Click:Connect(function()
cash.Value = cash.Value + reward
dailyRewardGui.Enabled = false
local streak = streak + 1
if streak > 7 then streak = 1 end
pcall(function()
dailyRewardDS:SetAsync(plr.UserId .. "-DailyRewards", {cash.Value, os.time(), streak})
end)
end)
end
end
end)
Gamepass Script:
game.Players.PlayerAdded:Connect(function(player)
wait(5)
local marketservice = game:GetService("MarketplaceService")
local can = true
repeat wait() until player:FindFirstChild("leaderstats")
local leader = player:FindFirstChild("leaderstats")
if leader then
repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
if currency then
local folder = Instance.new("Folder",player)
folder.Name = "2xGamepass"
local oldmoney = Instance.new("IntValue",folder)
oldmoney.Name = "OldMoney"
oldmoney.Value = currency.Value
local give2x = Instance.new("IntValue",folder)
give2x.Name = "Give2x"
give2x.Value = 0
currency.Changed:Connect(function()
if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then
if can == true then
can = false
if currency.Value > oldmoney.Value then
give2x.Value = currency.Value - oldmoney.Value
currency.Value = currency.Value + give2x.Value
oldmoney.Value = currency.Value
can = true
else
oldmoney.Value = currency.Value
can = true
end
end
else
oldmoney.Value = currency.Value
end
end)
end
end
end)