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

DataStore script is "Missing an Argument" when I'm not. Any help?

Asked by 6 years ago

Hey, so I have this data store script/leaderstats script. It keeps spitting out an error which is "Missing Argument 1 on Line 2" so... yeah. THIS IS A REGULAR SCRIPT BTW.

local DataStoreService = game:GetService('DataStoreService')
local DataCredits = DataStoreService:GetDataStore(credits)
local DataPremium = DataStoreService:GetDataStore(premium)

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new('Folder')
    leaderstats.Name = 'leaderstats'
    leaderstats.Parent = player
    local playerCredits = Instance.new('IntValue')
    playerCredits.Name = 'Credits'
    playerCredits.Parent = player.leaderstats
    playerCredits.Value = DataCredits:GetAsync(player.UserId)
    local playerPremiumSessions = Instance.new('IntValue')
    playerPremiumSessions.Name = 'PremiumRemaining'
    playerPremiumSessions.Parent = player.leaderstats
    playerPremiumSessions.Value = DataPremium:GetAsync(player.UserId)
end)

game.Players.PlayerRemoving:connect(function(player)
    DataCredits:SetAsync(player.userId, player.leaderstats.Credits.Value)
    DataPremium:SetAsync(player.userId, player.leaderstats.PremiumRemaining.Value)
end)

This is also being consistent with Line 3.

0
My line 21 isn't on 2 lines, it's just no space. AwesomeUniverseYT 56 — 6y
0
have you defined credits/premium? or at least putting quotation marks around them. abnotaddable 920 — 6y
0
You haven't showed what you assigned 'credits' nor 'premium' to. GetDataStore's argument requires a string, so you'll have to put quotation marks around credits and premium Rare_tendo 3000 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

As stated in the comments, GetDataStore's argument requires a string.
Looking at your code, you have not defined the variable "credits" or the variable "premium". A simple way to fix this is to use quotation marks "like this", So line 2 and 3 would look like:

local DataCredits = DataStoreService:GetDataStore("credits")
local DataPremium = DataStoreService:GetDataStore("premium")
0
Great! Works good! AwesomeUniverseYT 56 — 6y
Ad

Answer this question