Hello, so i'm trying to load value from ReplicatedStorage into a normal leaderboard, but it just keep saying "ServerScriptService.LinkedLeaderboard:138: attempt to index a nil value".
Problem is in these lines:(Original lines)
local PlayerStats = game.ReplicatedStorage.PlayerStorage.Store:FindFirstChild(newPlayer.Name).PointsStorage if PlayerStats ~= nil then if cash then local Short = Settings.LeaderboardSettings.ShowShortCurrency PlayerStats.Changed:connect(function() if (Short) then cash.Value = Settings:ConvertShort(PlayerStats.Value) else cash.Value = Settings:ConvertComma(PlayerStats.Value) end end) end end
Even i tried to separate PointsStorage from it and add new line with it.
Here is changed a bit script:
local PlayerStats = game.ReplicatedStorage.PlayerStorage.Store:FindFirstChild(newPlayer.Name) if PlayerStats ~= nil then local plrStats = PlayerStats:FindFirstChild("PointsStorage") if plrStats ~= nil then if cash then local Short = Settings.LeaderboardSettings.ShowShortCurrency plrStats.Changed:connect(function() if (Short) then cash.Value = Settings:ConvertShort(plrStats.Value) else cash.Value = Settings:ConvertComma(plrStats.Value) end end) end end end
Error dissapeared, but script still don't work..
I think I see a problem. Scripts mostly load in first then other objects, and it will immediately execute the code within the script. Instead of game.ReplicatedStorage.PlayerStorage
you should use the :WaitForChild("object name here")
, that why the script will wait for the object to be there.
Example:
local RP = game:GetService("ReplicatedStorage") RP:WaitForChild("PlayerStorage"):WaitForChild("Store") --and such
I hope this helped but if this somehow did not work, I do not know what to do after that.
I'm noticing that cash either wasnt made or isnt visible. Please, if any if statements dont work, you must test and fix those immediately. I recommend using print statements