So I am using DataStore2, and I am wanting to fire a RemoteEvent, which should Increment (Add) onto the players points and rubies. Rubies is working fine, not the points tho. It’s giving an error, which the error is the title of this topic.
Here is my script:
game.ReplicatedStorage.Increment1.OnServerEvent:Connect(function(player)
local pointsStore1 = DataStore2("points", player)
local rubysStore1 = DataStore2("rubys", player)
pointsStore1:Increment(1)
rubysStore1:Increment(1)
-- wait
wait(.2)
pointsStore1:Increment(-1)
rubysStore1:Increment(-1)
end)
I’m confused on why the data store’s parameters are (“points”, player). The proper syntax is ([key], [value]) as in DataStore2(playerid, value). In your case, “points” as a key doesn’t make sense since you’re setting the key “points” to the value of the player.
Sorry for getting back so late, you probably already solved this, lol.
you would do something like the following to set a player’s stat:
-- reference the datastore first
local pointsStore1 = DataStoreService:GetDataStore("points")
-- set the specific player's stat by using their userid and their point count
local success, errorMessage = pcall(function()
pointsStore1:SetAsync(player.UserId, numPoints)
end)
I’d highly recommend looking at a tutorial on the topic, such as