You can use the keyword returnto return the points to the localscript.
So, it can be:
local DataStorePoints = game:GetService("DataStoreService"):GetDataStore("Points")
function dataGetEvent.OnServerInvoke(player, item)
if (item == "points") then
return DataStorePoints:GetAsync("user_"..tostring(player.UserId)..", points) or nil
end
end
In the localscript, the player will ask for points, the function dataGetEvent will be fired with the arguments: maquilaque (example), points
If the item is the points, then it will return from the DataStore Service, called from the :GetService() method,* a variable*.
From DataStoreService, we get the store "Points", and to get the player's stuff, we use a key. In this example, the key is user_"..tostring(player.UserId)", so mine could be "user_25776731" because my Id is 25776731.
Then we call a scope to get the points, in this case, it's "points".
All this stuff will be returned with the keyword return, but if doesn't exist, then it will return nil.
Hope it will work!
Don't forget to accept my answer if it works!
3 comments
returnis not a function, it's a keyword.Ok thanks I'll correct it!
Thanks, and you also don't need the tostring