Im not even sure how this is possible or where to start on fixing it, my leaderstats script which has worked fine and has been untouched for weeks now all of a sudden stop workings
https://gyazo.com/c1fc2e71754e5f5c91ade383307f01d1
Nothing, or at least most of them no longer exist apparently though the script like I said is unchanged and looks like this:
(and so on for the rest)
It seems to be random for which stats load in or not each time I test it
1 Like
May I ask if the leaderstats show up in the top right corner?
Edit: like this:

They do not,
just to add more characters
1 Like
Is there anything that lags your game at the start? an example would be large part counts, mass asset loading?
No, though I feel im onto a solution, when ive highlighted out these two:

(Specifically the top one, as ive had the bottom one for weeks working) The rest of the stats load.
Im not sure why this would be the case?
Edit I see the issue, both called the same thing, stupid mistake. nevermind, changing the name did not stop the problem
1 Like
Are you trying to make the string values appear in the leaderstats?
1 Like
Ah, looks like I didn’t read the entire post. My bad.
1 Like
Could you show me the output for the .PlayerAdded
event?
If you don’t know what I mean, basically it could be that there is no OwnedSkins
in ReplicatedStorage
and if there is, it hasn’t loaded yet.
Its weird because owned skin does exist

And ive seen it add the folder into OwnedItems but not OwnedSkins even though both are using the same code
1 Like
Try using something like this:
-- services
local players = game:GetService("Players")
-- functions
local function PlayerAdded(player)
if (player:FindFirstChild("leaderstats")) then
return
end
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
end
for index,player in pairs(players:GetPlayers()) do
PlayerAdded(player)
end
players.PlayerAdded:Connect(PlayerAdded)
In the PlayerAdded function put your code in, but keep this:
if (player:FindFirstChild("leaderstats")) then
return
end
At the top of the function.
Edit: In your code it says game.ReplicatedStorage.OwnedItem
should it not be game.ReplicatedStorage.OwnedItems
?
I seem to have fixed it by putting a wait for child on replicated storage, though now every script loads before the stats which can be fixed with a waitforchild but never happened before
2 Likes
Could it also be that the local script is running the moment the player spawns, which doesn’t give the leaderstats enough time to load in?
1 Like
At first, no because I could see they just didnt exist at all, but now yes that is the case which ive just fixed by putting these 2:
At the bottom of the script
2 Likes
I’ve never seen someone use game:WaitForChild("ReplicatedStorage")
before but one last thing, if that works you could try game.ReplicatedStorage:WaitForChild("OwnedItems")
.
Yeah it was just because I was trying everything at that point
Edit: Theirs still the issue of local scripts running before all the stats have loaded in which never happened before after a couple tries of testing
1 Like
There is an easy fix for that:
Replace all the game.ReplicatedStorage.OwnedItems
(applies for all folders in the player or any parent) with:
game.ReplicatedStorage:WaitForChild("OwnedItems",60)
1 Like
Fixed by just putting waitforchilds absolutely everywhere, not sure why it suddenly became an issue now and never before but yeah.