Attempt to index nil with number?

So basically I am working on a script and I get this error once I use my code:

user_Replay.rbxmx.Replay.Script:121: attempt to index nil with number  -  Edit - Script:121

So I am wondering how do I fix this?
Code:

local function UpdateRecordings(recording)
	getRecordings()
	
	local idToUse = 0
	
	local ID = plugin:GetSetting(IdKey)
	
	if ID then
		idToUse = ID
	else
		idToUse = 0
	end
	
	recordings[idToUse] = recording
	plugin:SetSetting(IdKey,idToUse + 1) -- update the ID
	
	plugin:SetSetting(key,recordings) -- update recordings
end

2 Likes

I don’t know where are you getting the ID, are you trying to find a number from a value?

Try using tonumber(id) if what I said is true, it will search the number of a string/value and make it numbers.

2 Likes

So I tried using tonumber but it still not working. It should so I have a feeling it has to do with they key.

So with plugins you can use something called :GetSetting(key, value)
I am not sure if the key has to be a number. Im going to do some more experiments with it

I figured it out. Dont worry I get this. Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.