Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with For Loop?

Asked by 8 years ago

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!

0
Is the goal to build a list of GUIs, and add one to the bottom each time the key is pressed? BlueTaslem 18071 — 8y
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. intrance 50 — 8y

1 answer

Log in to vote
-1
Answered by 8 years ago

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
0
num isn't defined intrance 50 — 8y
Ad

Answer this question