Im NEW to scripting!! Im trying to make a daily reward system but the thing is it makes a whole new currency on my leader board. I already have a leaderstats script so i dont know why its making another currency.
local dss = game:GetService("DataStoreService")
local dailyRewardDS = dss:GetDataStore("DailyRewards")
local rewardsForStreak =
{
[1] = 100,
[2] = 250,
[3] = 500,
[4] = 1000,
[5] = 1750,
[6] = 3000,
[7] = 7500,
}
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 leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = dailyRewardInfo[1] or 0
cash.Parent = leaderstats
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)
and heres the script were the normal leaderstats came from its my character shop
local onJoin = function(player)
-- This is where we stored player money.
local stats = Instance.new("Folder")
stats.Parent = player
stats.Name = "leaderstats"
-- This is where we store the purchased character.
local characterfolder = Instance.new("Folder")
characterfolder.Parent = player
characterfolder.Name = "Characters"
-- Player's currency for the character shop.
local money = Instance.new("IntValue")
money.Parent = stats
money.Name = "Money"
-- Equipped Character Value
local EquippedCharacter = Instance.new("StringValue")
EquippedCharacter.Parent = player
EquippedCharacter.Name = "EquippedCharacter"
end
game.Players.PlayerAdded:Connect(onJoin)

4 comments
i removed the one in the first script but then it still does not add to the second script?
What? I don't understand you.
i mean the first script is a daily reward for the "money" folder so basically the daily reward adds to the "money" folder
but the script wont add the currency to the leader stats im trying to figure out why its not