You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a data saving system for aura storing.
What is the issue? Include screenshots / videos if possible!
Everytime I press play, I get an error. (Duo testing and it works for my friend but not me)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried reopening studio, changing the code and looked for solutions on the developer forum but I did not find anything.
local data
local success, errormessage = pcall(function()
data = playerdataservice:GetAsync(plr.UserId, dataname)[object] -- Error here :c
end)
if success and data then
print("Data found.")
return data
else
return print("No data was found.")
end
Is playerdataservice another module or is it a datastore object? If the latter, the second argument of :GetAsync is a DataStoreGetOptions which I’m guessing dataname is not, you should be able to omit it from your GetAsync call entirely
It is the store that I use to save the player’s data.
local playerdataservice = dataservice:GetDataStore("PlayerExperience")
The function is not being used yet I am still getting this error. I thought that it had to be used first, but I could not find anything close to PcallStore. (the function)
And what do you mean by DataStoreGetOptions?
DataStoreService:GetDataStore() returns a GlobalDataStore object, the error here is caused by attempting to call GlobalDataStore:GetAsync() with the second argument being invalid
basically DataStoreGetOptions is an instance that lets you change how the datastore is accessed, which currently is just for disabling caching on requests for it
the problem here is that GetAsync()'s second parameter takes either nothing or a DataStoreGetOptions instance, if you simply remove the second argument it should work
what i think you meant to do is specify a scope for the get request, which is done in DataStoreService:GetDataStore() instead in the second argument, or by adding a prefix to the first argument of GetAsync() (example: scope/key)
i’m a bit confused by what you mean, try placing breakpoints around your script to figure out exactly where the error is since pcall could be throwing away the stack trace
I’m guessing this is to load data and you want to get an object of that data.
Try doing this instead and see if it works:
local success, data = pcall(function()
return playerdataservice:GetAsync(plr.UserId) -- no need for dataname variable
end)
if success and data then
print("Data found.")
return data
else
return print("No data was found.")
end
I’m unsure of what the object is, but I’m sure when you return the data you can simply just do:
local data;
local foo= PcallStore();
if foo then
data = foo[object];
end
I tried this again but changing it up a little bit, and it sort of worked… I’m still not sure if it would work as I expected it to, but I hope it does work once I make the function add data. (maybe I already have that, I just forgot?)
Edit: I’m gonna mark your post as the solution, but I’m still not sure if this will work. If it is not gonna work later, then I’m probably gonna undo it.