Why does it print, but not run the code between it?

Hi, something very weird is happening with my code. I have created a custom function that prints something and then equips a table skin. The thing is that the script only runs the print() functions but not any of the other code… Here’s my script:

local function equiptable(tableframe : Frame)
	-- equip table
	-- this print() runs
	print("equip "..tableframe.Name)
    -- the stuff under here does'nt run
	tableframe.Equiped.Value = true

	tableframe.Buy.BackgroundColor3 = Color3.fromRGB(255, 67, 67)
	tableframe.Buy.Text = "Equipped"

	-- unequip other tables
	
	for i, v in pairs(tableframe.Parent:GetChildren()) do
		if v:IsA("Frame") and v ~= tableframe and v.Bought.Value then
			-- this print() runs
			print("unequip "..v.Name)
            -- but not any of this down here
			tableframe.Equiped.Value = false

			tableframe.Buy.BackgroundColor3 = Color3.fromRGB(46, 156, 229)
			tableframe.Buy.Text = "Equip"
		end
	end
end

Thanks

Why do you think the code isn’t running?

At the beginning of the function, you’re equipping the table passed into the function

tableframe.Equiped.Value = true

tableframe.Buy.BackgroundColor3 = Color3.fromRGB(255, 67, 67)
tableframe.Buy.Text = "Equipped"

But within the for loop you’re unequipping the same table

tableframe.Equiped.Value = false

tableframe.Buy.BackgroundColor3 = Color3.fromRGB(46, 156, 229)
tableframe.Buy.Text = "Equip"

I assume you want to set these values on v and not tableframe right?

1 Like

oh whoops! thanks for the answer lol. Rookie mistake on my part :man_facepalming:

1 Like