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:
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/f/b/6/fb609ebacf8e0424d84302269596e62f3a2339dd.png)
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:
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/7/9/d/79df8bfba253c72f7dd7b5b3e8c0ac53a4fce4b3.png)
(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
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/e/9/1/e91300ca3bc83ddf0a8c9fc4276fdecdcaff5e6b.png)
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.