Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Did you forget a colon? The first argument of member function GetAsync must be an Object

Asked by 5 years ago

local module = {}

local DataStore = game:GetService("DataStoreService"):GetDataStore("M12341123231")

local StarterPounds = 0

game.Players.PlayerAdded:connect(function(player) local Stats = Instance.new('Folder', player) Stats.Name = "Stats"

local Pounds = Instance.new('NumberValue', player)
Pounds.Name = "Pounds"
Pounds.Value = StarterPounds
Pounds.Parent = Stats

local SavedPounds = DataStore.GetAsync(player.UserId..'-Pounds')
if SavedPounds == nil then
    Pounds.Value = SavedPounds
end 

end)

game.Players.PlayerRemoving:connect(function(player) local id = player.UserId local PoundsValue = player.Stats.Pounds.Value DataStore:SetAsync(id..'-Pounds', PoundsValue) end) return module

Whenever I change the first argument I get UserId isn't a valid member of Player.~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~

0
You do DataStore.GetAsync(DataStore, player.UserId..-'Pounds') User#19524 175 — 5y
0
Or you can use syntax sugar and use DataStore:GetAsync(player.UserId..-'Pounds'). User#19524 175 — 5y
1
next time, don't use the parent parameter of Instance.new(), as that causes performance issues theking48989987 2147 — 5y

1 answer

Log in to vote
0
Answered by
Vmena 87
5 years ago

You are using the following:

DataStore.GetAsync()

You should be using the following:

DataStore:GetAsync()

GetAsync is a function, not a property, so it must be called upon with a colon rather than a period.

Ad

Answer this question