Raised and donated script dont work

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

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

--columns of default leaderboard
local donated = Instance.new("StringValue")
donated.Name = "Donated"
donated.Parent = leaderstats

local raised = Instance.new("StringValue")
raised.Name = "Raised"
raised.Parent = leaderstats
raised.Parent = leaderstats`

Capture
`

1 Like

I have added stringvalue too and it still dont work

Is there an end) anywhere after Line 14?

1 Like

will try that now! i think i forgot to put end) so will try that now and will let you know

2 Likes

alright so the end) 1. made the booth earn at blank and it still does not work in donation and raised

Can you paste the entire script here (in a code block), and also show a screenshot of the error that’s appearing in the output?

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

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

--columns of default leaderboard
local donated = Instance.new("StringValue")
donated.Name = "Donated"
donated.Parent = leaderstats
donated.Value  = 0

local raised = Instance.new("StringValue")
raised.Name = "Raised"
raised.Parent = leaderstats
raised.Value  = 0

end)

there no error in the output but the leaderstats dont update when someone donates

Can you show the code you made that is intended to make the leaderboard update when someone donates?

local ProfileService = require(game.ReplicatedStorage.ProfileService)
local Players = game:GetService(“Players”)
local Profiles = {}

local saveStructure = {
Donated = 0;
Raised = 0;
}

local PlayerProfileStore = ProfileService.GetProfileStore(“PlayerSaveData”, saveStructure)

local function PlayerDataLoaded(player)
local profile = Profiles[player]

local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player

local Donated = Instance.new("IntValue")
Donated.Name = "Donated"
Donated.Value = profile.Data.Donated
Donated.Parent = folder

local Raised = Instance.new("IntValue")
Raised.Name = "Raised"
Raised.Value = profile.Data.Raised
Raised.Parent = folder

spawn(function()
        local profile = Profiles[player]

        if profile ~= nil then
            Donated.Value = profile.Data.Donated
            Raised.Value = profile.Data.Raised
        end
end)

end

local function PlayerAdded(player)
local profile = PlayerProfileStore:LoadProfileAsync(“Player” … player.UserId, “ForceLoad”)
if profile ~= nil then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick(“Your profile has been loaded remotely. Please rejoin.”)
end)

    if player:IsDescendantOf(Players) then
        Profiles[player] = profile
        PlayerDataLoaded(player)
    else
        profile:Release()
    end
else
    player:Kick("Unable to load saved data. Please rejoin.")
end

end

for , player in ipairs(Players:GetPlayers()) do
spawn(function()
PlayerAdded(player)
end)
end

Players.PlayerAdded:Connect(PlayerAdded)

Players.PlayerRemoving:Connect(function(player)
local profile = Profiles[player]
if profile ~= nil then
profile:Release()
end
end)

local function AddRaised(userID, amount)
local player = Players:GetPlayerByUserId(userID)
if player then
local profile = Profiles[player]
profile.Data.Raised = profile.Data.Raised + amount
end
end

local function AddDonated(userID, amount)
local player = Players:GetPlayerByUserId(userID)
if player then
local profile = Profiles[player]
profile.Data.Donated = profile.Data.Donated + amount
end
end

game.ReplicatedStorage.Events.AddValue.Event:Connect(function(userID, amount, stat)
if stat == “Raised” then
AddRaised(userID, amount)
elseif stat == “Donated” then
AddDonated(userID, amount)
end
end)

local GetDataEvent = game.ReplicatedStorage.Events.GetDataEvent

GetDataEvent.OnServerEvent:Connect(function(player, userID, stat, val)
local profile = Profiles[player]

GetDataEvent:FireClient(player, profile.Data[stat], val)

end)

local ProfileService = require(game.ReplicatedStorage.ProfileService)
local Players = game:GetService(“Players”)
local Profiles = {}

local saveStructure = {
Donated = 0;
Raised = 0;
}

local PlayerProfileStore = ProfileService.GetProfileStore(“PlayerSaveData”, saveStructure)

local function PlayerDataLoaded(player)
local profile = Profiles[player]

local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player

local Donated = Instance.new("IntValue")
Donated.Name = "Donated"
Donated.Value = profile.Data.Donated
Donated.Parent = folder

local Raised = Instance.new("IntValue")
Raised.Name = "Raised"
Raised.Value = profile.Data.Raised
Raised.Parent = folder

spawn(function()
        local profile = Profiles[player]

        if profile ~= nil then
            Donated.Value = profile.Data.Donated
            Raised.Value = profile.Data.Raised
        end
end)

end

local function PlayerAdded(player)
local profile = PlayerProfileStore:LoadProfileAsync(“Player” … player.UserId, “ForceLoad”)
if profile ~= nil then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick(“Your profile has been loaded remotely. Please rejoin.”)
end)

    if player:IsDescendantOf(Players) then
        Profiles[player] = profile
        PlayerDataLoaded(player)
    else
        profile:Release()
    end
else
    player:Kick("Unable to load saved data. Please rejoin.")
end

end

for , player in ipairs(Players:GetPlayers()) do
spawn(function()
PlayerAdded(player)
end)
end

Players.PlayerAdded:Connect(PlayerAdded)

Players.PlayerRemoving:Connect(function(player)
local profile = Profiles[player]
if profile ~= nil then
profile:Release()
end
end)

local function AddRaised(userID, amount)
local player = Players:GetPlayerByUserId(userID)
if player then
local profile = Profiles[player]
profile.Data.Raised = profile.Data.Raised + amount
end
end

local function AddDonated(userID, amount)
local player = Players:GetPlayerByUserId(userID)
if player then
local profile = Profiles[player]
profile.Data.Donated = profile.Data.Donated + amount
end
end

game.ReplicatedStorage.Events.AddValue.Event:Connect(function(userID, amount, stat)
if stat == “Raised” then
AddRaised(userID, amount)
elseif stat == “Donated” then
AddDonated(userID, amount)
end
end)

local GetDataEvent = game.ReplicatedStorage.Events.GetDataEvent

GetDataEvent.OnServerEvent:Connect(function(player, userID, stat, val)
local profile = Profiles[player]

GetDataEvent:FireClient(player, profile.Data[stat], val)

end)

Capture