Leaderstats Script Not Working. Please Help!

there is, actually… its for like chat messages for when someone joins and leaves, could that be it?

Go and have a look…?

Is there anything that’s modifying the values in leaderstats at all?

okay

(30303003030303030303030)

ok so theres one script that says this…

local events = game.ReplicatedStorage.Events

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

events.Added:FireAllClients(plr)

end)

game.Players.PlayerRemoving:Connect(function(plr)

events.Removing:FireAllClients(plr)

end)

does that effect it?

ok, i gotta go… can we finish this up tomorrow please?

Have you tried indexing the data table with strings, instead of just data.orbs? I’m not sure if it makes a difference.


data["Orbs"]

That does not do anything with leaderstats, so I believe this doesn’t cause the issue. Any other script related to datastores? If not, then… I don’t know, roblox might be down…

Uhm, yes… actually 2. one is alvinblox’s egg system… but i dont think thats it… i think it might be the global orb leaderboard i have…?

because, this issue wasnt happening before i added it i dont think…

Give me a minute, I’m testing your game.

ok…

(33030303030303030)

I collected 1,200 coins. And after rejoining, I got 1,200 coins, and 1,200 orbs. Really strange.

Could you show the script of the orbs leaderstats board, and the coins leaderstats board?

ok, theres a few different scripts for it, ill show them though, all the same scripts just changed in currencies.

Ok so heres the one for the refreshing part

local NumberValue = script.Parent.Parent.Parent.NumberValue

while true do
wait(1)
if NumberValue.Value > 0 then
NumberValue.Value = NumberValue.Value - 1
script.Parent.Text = "Global board refreshes in "… NumberValue.Value… “s”
end

if NumberValue.Value == 0 then
	script.Parent.Text = "Refreshing global board"
	wait(2)
	NumberValue.Value = 180
end

end

heres the datastore for it

local DS = game:GetService(“DataStoreService”):GetDataStore(“SaveMyData”)
game.Players.PlayerAdded:Connect(function(plr)
wait(4)
local plrkey = “Id_”…plr.UserId
local savevalue = plr.leaderstats.Orbs

local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
	savevalue.Value = GetSaved[1]
else
	local NumbersForSaving = {savevalue.Value}
	DS:GetAsync(plrkey, NumbersForSaving)
end

end)

game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync(“Id_”…plr.UserId, {plr.leaderstats.Orbs.Value})
end)

and heres the script that makes it function or idk…

local TotalOrbsODS = game:GetService(“DataStoreService”):GetOrderedDataStore(“Orbs”)

local function Handler()
local Success, Err = pcall(function()
local Data = TotalOrbsODS:GetSortedAsync(false, 25)
local TotalOrbsPage = Data:GetCurrentPage()
for Rank, Data in ipairs(TotalOrbsPage) do
local Name = Data.key
local TotalOrbs = Data.value
local NewObj = game.ReplicatedStorage:WaitForChild(“OrbsFrame”):Clone()
NewObj.Player.Text = Name
NewObj.TotalOrbs.Text = TotalOrbs
NewObj.Rank.Text = “#”…Rank
NewObj.Position = UDim2.new(0, 0, NewObj.Position.Y.Scale + (0.08 * #game.Workspace.StatOrbsBoard.lbGUI.Holder:GetChildren()), 0)
NewObj.Parent = game.Workspace.StatOrbsBoard.lbGUI.Holder
if Rank == 1 then
NewObj.Rank.TextColor3 = Color3.fromRGB(255, 238, 0)
NewObj.Player.TextColor3 = Color3.fromRGB(255, 238, 0)
NewObj.TotalOrbs.TextColor3 = Color3.fromRGB(255, 238, 0)
elseif Rank == 2 then
NewObj.Rank.TextColor3 = Color3.fromRGB(179, 179, 179)
NewObj.Player.TextColor3 = Color3.fromRGB(179, 179, 179)
NewObj.TotalOrbs.TextColor3 = Color3.fromRGB(179, 179, 179)
elseif Rank == 3 then
NewObj.Rank.TextColor3 = Color3.fromRGB(207, 155, 0)
NewObj.Player.TextColor3 = Color3.fromRGB(207, 155, 0)
NewObj.TotalOrbs.TextColor3 = Color3.fromRGB(207, 155, 0)

		elseif Rank > 10 then
			NewObj:Destroy()
		end
    end
end)
if not Success then
    error(Err)
end

end

local OrbsBoardRefreshTimer = game.Workspace.BoardRefreshTimer.MainPart

OrbsBoardRefreshTimer.NumberValue.Changed:Connect(function()
if OrbsBoardRefreshTimer.NumberValue.Value == 0 then
for _,Player in pairs(game.Players:GetPlayers()) do
TotalOrbsODS:SetAsync(Player.Name, Player.leaderstats.Orbs.Value)
end
for _,v in pairs(game.Workspace.StatOrbsBoard.lbGUI.Holder:GetChildren()) do
if v.Name == “OrbsFrame” then
wait()
v:Destroy()
end
end
Handler()
end
end)

and, i think thats it!

1 Like

Please put them in code blocks like so;

```lua
-- code here
```
```lua
local DS = game:GetService("DataStoreService"):GetDataStore("SaveMyData")
game.Players.PlayerAdded:Connect(function(plr)
	wait(4)
	local plrkey = "Id_"..plr.UserId
	local savevalue = plr.leaderstats.Orbs
	
	local GetSaved = DS:GetAsync(plrkey)
	if GetSaved then
		savevalue.Value = GetSaved[1]
	else
		local NumbersForSaving = {savevalue.Value}
		DS:GetAsync(plrkey, NumbersForSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	DS:SetAsync("Id_"..plr.UserId, {plr.leaderstats.Orbs.Value})
end)
like that?
1 Like

You did it, it seems that you have typed ```lua twice

oh, oops. and okay!

local TotalOrbsODS = game:GetService("DataStoreService"):GetOrderedDataStore("Orbs")
 
local function Handler()
    local Success, Err = pcall(function()
        local Data = TotalOrbsODS:GetSortedAsync(false, 25)
        local TotalOrbsPage = Data:GetCurrentPage()
        for Rank, Data in ipairs(TotalOrbsPage) do
            local Name = Data.key
            local TotalOrbs = Data.value
            local NewObj = game.ReplicatedStorage:WaitForChild("OrbsFrame"):Clone()
            NewObj.Player.Text = Name
			NewObj.TotalOrbs.Text = TotalOrbs
            NewObj.Rank.Text = "#"..Rank
            NewObj.Position = UDim2.new(0, 0, NewObj.Position.Y.Scale + (0.08 * #game.Workspace.StatOrbsBoard.lbGUI.Holder:GetChildren()), 0)
            NewObj.Parent = game.Workspace.StatOrbsBoard.lbGUI.Holder
			if Rank == 1 then
				NewObj.Rank.TextColor3 = Color3.fromRGB(255, 238, 0)
				NewObj.Player.TextColor3 = Color3.fromRGB(255, 238, 0)
				NewObj.TotalOrbs.TextColor3 = Color3.fromRGB(255, 238, 0)
			elseif Rank == 2 then
				NewObj.Rank.TextColor3 = Color3.fromRGB(179, 179, 179)
				NewObj.Player.TextColor3 = Color3.fromRGB(179, 179, 179)
				NewObj.TotalOrbs.TextColor3 = Color3.fromRGB(179, 179, 179)
			elseif Rank == 3 then
				NewObj.Rank.TextColor3 = Color3.fromRGB(207, 155, 0)
				NewObj.Player.TextColor3 = Color3.fromRGB(207, 155, 0)
				NewObj.TotalOrbs.TextColor3 = Color3.fromRGB(207, 155, 0)
				
			elseif Rank > 10 then
				NewObj:Destroy()
			end
        end
    end)
    if not Success then
        error(Err)
    end
end

local OrbsBoardRefreshTimer = game.Workspace.BoardRefreshTimer.MainPart

OrbsBoardRefreshTimer.NumberValue.Changed:Connect(function()
	if OrbsBoardRefreshTimer.NumberValue.Value == 0 then
		    for _,Player in pairs(game.Players:GetPlayers()) do
       			 TotalOrbsODS:SetAsync(Player.Name, Player.leaderstats.Orbs.Value)
    			end
    	for _,v in pairs(game.Workspace.StatOrbsBoard.lbGUI.Holder:GetChildren()) do
        if v.Name == "OrbsFrame" then
			wait()
            v:Destroy()
        end
    end
    Handler()
	end
end)
local NumberValue = script.Parent.Parent.Parent.NumberValue

while true do
	wait(1)
	if NumberValue.Value > 0 then
		NumberValue.Value = NumberValue.Value - 1
		script.Parent.Text = "Global board refreshes in ".. NumberValue.Value.. "s"
	end
	
	if NumberValue.Value == 0 then
		script.Parent.Text = "Refreshing global board"
		wait(2)
		NumberValue.Value = 180
	end
end

ok theres the scripts