Still have questions? Join our Discord server and get real time help.
Log in to vote

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

Asked by 11 months 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)

    local leaderstats ='Folder')
    leaderstats.Name = 'leaderstats'
    leaderstats.Parent = player
    local playerCredits ='IntValue')
    playerCredits.Name = 'Credits'
    playerCredits.Parent = player.leaderstats
    playerCredits.Value = DataCredits:GetAsync(player.UserId)
    local playerPremiumSessions ='IntValue')
    playerPremiumSessions.Name = 'PremiumRemaining'
    playerPremiumSessions.Parent = player.leaderstats
    playerPremiumSessions.Value = DataPremium:GetAsync(player.UserId)

    DataCredits:SetAsync(player.userId, player.leaderstats.Credits.Value)
    DataPremium:SetAsync(player.userId, player.leaderstats.PremiumRemaining.Value)

This is also being consistent with Line 3.

My line 21 isn't on 2 lines, it's just no space. AwesomeUniverseYT 37 — 11mo
have you defined credits/premium? or at least putting quotation marks around them. abnotaddable 895 — 11mo
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 doobmaster79 2330 — 11mo

1 answer

Log in to vote
Answered by 11 months ago
Edited 11 months 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")
Great! Works good! AwesomeUniverseYT 37 — 11mo

Answer this question