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

THIS IS THE ERROR BAD ARGUMENT #3 TO "NAME"(STRING EXPECTED, GOT OBJECT) HOW TO FIX? [closed]

Asked by 6 years ago

i am trying to do data saving thingy but it got a ton of errors on the script pls help the output keeps saying this error: ServerScriptService.datasave:6 bad argument #3 to "Name" {string expected ,got OBJECT} HELP

local DSService = game:GetService('DataStoreService'):GetDataStore('ForgottenCollapse') game.Players.PlayerAdded:connect(function(plr) local uniquekey = 'id-'..plr.UserId local leaderstats = Instance.new('IntValue',plr) local savevalue = Instance.new('IntValue') leaderstats.Name = leaderstats savevalue.Parent = leaderstats savevalue.Name = ("Money")

local GetSaved = DSService:GetAsync(uniquekey) if GetSaved then savevalue.Value = GetSaved[1] else local NumbersForSaving = {savevalue.Value} DSService:SetAsync(uniquekey, NumbersForSaving) end end)

game.Players.PlayerRemoving:connect(function(plr) local uniquekey = 'id-'..plr.UserId local Savetable = {plr.leaderstats.Dollars.Value} DSService:SetAsync(uniquekey, Savetable) end)

0
Do not post alvinbloxx's code expecting for it to be fixed. User#19524 175 — 6y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
waifuSZN 123
6 years ago
Edited 6 years ago
leaderstats = Instance.new('IntValue',plr)
leaderstats.Name = 'leaderstats'

The Name object of any property takes a string, but you defined Name as an object, which isn't possible.

Put it in quotes, my guy.

Ad