Local Script: Print statements not printing after cloning an imagelabel

For some unknown reason, my local script is not running properly where print statements are not printing after cloning an imagelabel.

I’ve tried to prevent it by commenting out any code referencing the clone, yet even then none of those print statements run.

local frame = workspace:WaitForChild("P2Screen").SurfaceGui.Frame
local layout = frame.UIListLayout
local card = game.ReplicatedStorage.Card
local cardsize = 109.89
local numcards = 1


local function spacingformula(cards)
	print("function") -- has not printed at all either
	local number = (frame.AbsoluteSize.X - (cards*cardsize))/cards
	if number < 0 then
		return number
	else
		return 0
	end
end

print(spacingformula(5)) -- printed nothing when ran

while task.wait(5) do
	print("woo")
	numcards += 1
	print("what")
	local newcard = card:Clone() -- no print statements past this point print anything
	print("cloned")
	newcard.Parent = frame
	local spacing = spacingformula(numcards)
	print("fdone")
	layout.Padding = UDim.new(0,spacing)
	print("done")
end

The only things that are printed into the console is “woo” and “what”.

Is there anything wrong with my script or is this more of an engine problem?

It appears that the code after local newcard = card:Clone() runs due to looking at the value of padding in the UiListLayout but the print statements do not output anything. It’s strange.

Are you getting any errors in the console possibly?

Nope. Console is blank apart from “woo” and “what”, the loop repeats itself, only printing “woo” and “what” yet none of the other print statements

Is “card” actually being cloned? It might not be working maybe

try printing out (card) in the console I guess? And then if that works you can possibly try to print card:Clone to see if that errors

The card definitely does get cloned, i can see it appear on the surface gui

Hm okay that’s weird. Maybe create an identical script but remove the while loop and just run the function by itself

Just did that, while loop removed it still only prints woo and what


there are two card imagelabels so it is cloning which means it does get past the cloning code, skipping any print statements after it or something though

1 Like

ok that’s really weird since I don’t see anything wrong with your code. You could try to just write the code manually instead of running a function

I am having the same problem, lol

seems like this could be a studio problem then

local layout = frame.UIListLayout
local card = game.ReplicatedStorage.Card
local cardsize = 109.89
local numcards = 1


print("woo")
numcards += 1
print("what")
local newcard = card:Clone()
print("cloned")
newcard.Parent = frame
print("parented")
local spacing = (frame.AbsoluteSize.X - (numcards*cardsize))/numcards
if spacing > 0 then
	spacing = 0
end
layout.Padding = UDim.new(0,spacing)
print("done")

new code, no functions, still only woo and what

1 Like

Yeah so probably an engine studio bug or something. I would do some testing myself but im at school rn so I cant