So I'm trying to make a shop, and when a player buys an item the following code runs. Everything prints just fine, and even at the end it prints true. However, the async is not updated and still returns false. Why?
button = script.Parent
price = 738
player = button.Parent.Parent.Parent.Parent.Parent.Parent.Parent
data = game:GetService("DataStoreService"):GetDataStore("MWTestData1")
function inventory(old)
if not old.arm then
print(player.Name.." hasn't bought the arm")
old.arm = true
game.ServerStorage.PlayerStats[player.Name].Stats.Points.Value = game.ServerStorage.PlayerStats[player.Name].Stats.Points.Value - price
print(player.Name.." purchased "..button.Parent.Name.."!")
pointskey = player.userId.."Points"
data:IncrementAsync(pointskey, -price)
points = game.ServerStorage.PlayerStats[player.Name].Stats.Points
points.Value = data:GetAsync(player.userId.."Points")
print(player.Name.."'s points: "..points.Value)
else
print("Arm already purchased")
end
print(old..": "..old.arm)
return old
end
function buyItem()
print(player.Name.." is attempting to buy "..button.Parent.Name)
if game.ServerStorage.PlayerStats[player.Name].Stats.Points.Value >= price then
print(player.Name.." has enough points")
data:UpdateAsync(player.userId.."Inventory",
inventory)
else
print(player.Name.." doesn't have enough points")
end
end
button.MouseButton1Click:connect(buyItem)
Thanks! --MightyWanderer

1 comment
But that's what I'm doing. If you read in the buyItem function, I have "data:UpdateAsync(player.userId.."Inventory", inventory)" --"inventory" in the second part refers to the inventory funtion up above, which works just like it says on the wiki.