I am making an admin and I want to know how I can make it wait to run the code when the user presses ok.
function amount() script.Parent.Parent.amount.Visible = true script.Parent.Parent.amount.OK.MouseButton1Click:Connect(function() script.Parent.Parent.amount.Visible = false number = tonumber(script.Parent.Parent.amount.input.Text) end) end function commands() local cmd = script.Parent.Parent.bar.Text if cmd == "cmds" then print("commands: \n cmds \n test") elseif cmd == "test" then amount() for i=1,number do print("hi") wait(0) end end end script.Parent.MouseButton1Click:Connect(commands)
Hello, zymletal!
You can use :Wait()
to make the script wait for the function to be triggered
function amount() script.Parent.Parent.amount.Visible = true script.Parent.Parent.amount.OK.MouseButton1Click:Wait() --Waits for the button to be pressed script.Parent.Parent.amount.Visible = false number = tonumber(script.Parent.Parent.amount.input.Text) end function commands() local cmd = script.Parent.Parent.bar.Text if cmd == "cmds" then print("commands: \n cmds \n test") elseif cmd == "test" then amount() for i=1,number do print("hi") wait(0) end end end script.Parent.MouseButton1Click:Connect(commands)