Attempt to index nil with 'IsA' error?

Hello, fella devs,

I am trying to make a shop system like Piggy/Teddy, but it keep giving me a weird error. I wonder why it says attempt to index nil with 'IsA'. Here is the script

Callback:

local status
	if btn:IsA("TextButton") or btn:IsA("ImageButton") then
		status = checkStatus(btn)
	end

Function:

local function checkStatus(btn)
	if btn.Info.Status.TextColor3 == colors["red"] then
		return "Selected"
	elseif btn.Info.Status.TextColor3 == colors["green"] then
		return "Owned"
	elseif btn.Info.Status.TextColor3 == colors["yellow"] then
		return "For Sale"
	elseif btn.Info.Status.TextColor3 == colors["neutral"] then
		return "Off-Sale"
	end
end

I still don’t get it. Why does it keep giving me the error?

get rid of the end on the calback. also it means btn is nil/not in the function/variable environment

The callback script has a extra “end” on it (Last line)

that is not the error. I just put the end in the last line. Stpid me

try printing it and if it returns nil then you might have changed the variable somewhere in the script

print(btn.Name)

New errorimage

oh, its a nil meaning you might have unset or changed the value somewhere

Idk what is the problem. But Im sure this is the cause of the error.image
It need to duplicate the template and set the parent to a targeted screen. Maybe the child didn’t parented at the same time. I also tried if btn:FindFirstChild("Info) then but still didn’t work

wait, how did you set the variable? did you set it by script.Parent.Parent… or did you do it by locating the TextButton?

edit: is the script inside the button?

image

is the script inside the button?

It inside MenuGui > Shop(Frame) > CharacterShopLocal(The script)

so the script is not inside the button?

Yes, absolutely. Why? is the script supposed to be in the button?

yes the script that clones gui to player gui should be inside the script so instead of locating it to the player gui you can just type script.Parent

I don’t understand, this script is from @GnomeCode Teddy Shop script and I just edit it. Why is it still has the error?

oh so you didn’t write the script? hmm wait

wait, in here what script did you think i was talking about?

the Function script and the Callback script

function script for what exactly