I’m having a problem with my leaderstats. When a player donates, the ‘Donated’ stat increments, but when the donator rejoins the game, their ‘Raised’ stat also increments.
Donated:
if success and result then
if isPurchased then
if assetId ~= GamepassID then
if player then
-- Update the Donated value in the player's profile
if tonumber(result.PriceInRobux) then
local donatedAmount = tonumber(result.PriceInRobux)
profile.Data.Donated += donatedAmount
if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Donated") then
player.leaderstats.Donated.Value += donatedAmount
else
warn("Leaderstats or Donated stat missing for player: " .. player.Name)
end
AddValueEvent:Fire(player.UserId, donatedAmount, "Donated")
-- Log the successful donation
if success then
print(player.Name .. " successfully donated " .. donatedAmount .. " Robux.")
else
warn("Failed to save updated Donated value for player: " .. player.Name)
end
end
end
Raised:
if GotDonatedPlr then
if GotDonatedPlr.leaderstats.Raised then
if tonumber(result.PriceInRobux) then
GotDonatedPlr.leaderstats.Raised.Value += tonumber(result.PriceInRobux)
AddValueEvent:Fire(GotDonatedPlr.UserId, tonumber(result.PriceInRobux), "Raised")
profile.Data.Raised += tonumber(result.PriceInRobux)
if not GotDonatedPlr then
warn("Failed to save Raised value for player: " .. GotDonatedName)
end