Reproduction Steps
When I set an attribute to my Player on StarterPlayer, it doesn’t appear on my player, and thus other local scripts aren’t able to do GetAttribute for it, causing my entire game to break
No can do. My character doesn’t auto load on start. I need these attributes set basically as soon as the player joins, as theres multiple scripts that require this information before the players character has loaded into the game
I actually see your issue, I ain’t sure if its thinking it’s getting changed on the server before you change the client. I tried 2 other ways to do what you wanted to do and it diddn’t work. You could try and do it on server but I ain’t sure why you need it on the client tho. If this helps if I need attributes I always put a folder in StarterGui and put attributes there but lots of people have different ways to use these.
Edit: It seems it only doesn’t work in StarterPlayerScripts because for me it works on StarterCharacterScripts. Try to use GetAttribute and stuff from StarterPlayerScripts script then edit this post it seems like attributes doesn’t work at all in StarterPlayerScripts
I mean either way, my bug report still stands. There’s no documentation stating that attributes shouldn’t be setable in StarterPlayerScripts, thus regardless of its right or wrong, this bug is still valid
This code should work as-is because LocalPlayer is implicit to LocalScripts and starter containers don’t copy until Loaded fires. That being said, I did some testing myself and it seems like this is a quirk of Immediate SignalBehaviour and how the player is created - you’re encountering a race condition.
If you’re using Default (Immediate) SignalBehaviour this code will resolve your issue:
local LocalPlayer = game:GetService("Players").LocalPlayer
task.defer(LocalPlayer.SetAttribute, LocalPlayer, "foobar", "foobar")
If you’re using Deferred SignalBehaviour then your original code will work without any changes needing to be made. I’d recommend deferring your attribute in the meantime so that it will set as soon as possible. Any code that requires the attribute should yield unless that code will predictably execute after the attribute has been set.
This happens because the player object gets replicated twice for arcane legacy reasons. All the player properties set in that context will actually get blown away, not just the attributes.
This is something that should have been dealt with properly earlier, an engineer is looking into a solution though it’s not trivial because there may be some backwards compatibility concerns.
Hey! Sorry we took so long, but we just released a fix that no longer replicates the Player object twice. Please let us know if your experience is still …experiencing this issue!
I’m closing this thread per the above reply from our Roblox Staff!
We assume the issue was fixed that time due to no feedback from the developer!
Feel free to file another bug report if the issue is still occurring!