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

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

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.~~~~~~~~~~~~~~~~~


3 comments

0

You do DataStore.GetAsync(DataStore, player.UserId..-'Pounds')

0

Or you can use syntax sugar and use DataStore:GetAsync(player.UserId..-'Pounds').

1

next time, don't use the parent parameter of Instance.new(), as that causes performance issues

1 answer

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.

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