Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with For Loop?

Okay so this is the code:

if key_code == 13 then

        local slot = l1:Clone()
		slot.Parent = l1.Parent
		slot.Name = "Slot"
		slot.Position = UDim2.new(0,0,0,55*num)
		slot.Text = player.Name
		slot.Visible = true

Basically I just want a for loop to run every time key code is 13. I need a for loop because I need the slot position to move down every time it runs. I think you would use a for loop in this situation. If there is an easier to just move down the slot position every time key code is 13, then please help me out. Thanks!

2 comments

0

Is the goal to build a list of GUIs, and add one to the bottom each time the key is pressed?

0

The goal is to just built a slot for the name. And every time the key is pressed, it'll create a slot right below the previous one.

1 answer

You would use a while loop.

while true do
	wait(.1)
	if key_code == 13 then
		local slot = l1:Clone()
		slot.Parent = l1.Parent
		slot.Name = "Slot"
		slot.Position = UDim2.new(0,0,0,55*num)
		slot.Text = player.Name
		slot.Visible = true
	end
end

1 comment

0

num isn't defined

This discussion is preserved as it was. New answers, comments, and votes are closed.