I am a bit new to datastores, and on a recent project no matter what I do I get a "request rejected" output where it says playerData:SetAsync()
It was working fine before until recently, not sure what happened. Anyone have any clue? It would be greatly appreciated!
local playerData = game:GetService("DataStoreService"):GetDataStore("Players", player.userId)
if(playerData:GetAsync("Data") == nil) then
local success, message = pcall(function()
playerData:SetAsync("Data", {Credits=0,
Cases={},
Guns={
Shotgun={"Default"},
LMG={"Default"},
SMG={"Default"},
Rifle={"Default"}
},
Characters={
Runner={},
Tank={},
Medic={},
Hunter={},
Monster={}
},
Hunter={Rank=1, XP=0, MaxXP=437, Gun="Default", Character="Default"},
Medic={Rank=1, XP=0, MaxXP=437, Gun="Default", Character="Default"},
Runner={Rank=1, XP=0, MaxXP=437, Gun="Default", Character="Default"},
Tank={Rank=1, XP=0, MaxXP=437, Gun="Default", Character="Default"},
Monster={Rank=1, XP=0, MaxXP=437, Character="Default"}
})
end)
if not success then
print("An error occurred: " .. message)
end
end
Edit: I am going to believe that this is a roblox side bug if no one can actually give me an answer to the problem.

4 comments
Are you getting the error in online servers? As well, you might want to swap
"Players"andplayer.userId: the scope of the data store is the second argument.Players is suppose to be the key, while the user id is the scope. So i can insert their user id to get the data on the player. Also, this is on servers on studio. Not play solo, I would double check on actual servers but Roblox currently has a massive bug where you can set up universes anymore. So i cant even test the game on roblox right now
That makes sense. Actually pretty clever. I'll steal that. I'm still looking into the bug here, but I can't find out anything so far.
Hey Adark, someone on RBXDev was able to help me out. Apparently the only way to currently get it working on studio is if i open it directly from roblox, which wasnt the case before. My code was fine. Thanks for helping though!