Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help Data store is not working?

I get this error "Did you forget a colon? The first argument of member function SetAsync must be an Object"

local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("MoneySaveSystem")

game.Players.PlayerAdded:connect(function(player)
	local Money = Instance.new("IntValue",player)
	Money.Name = "Money"
	Money.Value = ds:GetAsync(player.UserId) or 0
	ds:SetAsync(player.UserId, Money.Value)
	Money.Changed:connect(function()
		ds.SetAsync(player.UserId, Money.Value)
	end)
end)

game.Players.PlayerRemoving:connect(function(player)
	ds.SetAsync(player.UserId, player.Money.Value)
end)

1 comment

1

Firstly, it is supposed to be called with a colon, not a dot. [line 10 and 15]. Also, the first argument must be a string. Rather than player.UserId, put: tostring(player.UserId)

1 answer

✓ Accepted answer

It appears that you are doing .GetAsync and .SetAsync You have to do :GetAsync and :SetAsync

This discussion is preserved as it was. New answers, comments, and votes are closed.