Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local GUI = Instance.new("ScreenGui", game.CoreGui)
- GUI.Name = "my gui"
- local mainFrame = Instance.new("Frame", GUI)
- mainFrame.Name = "My frame"
- mainFrame.Size = UDim2.new(0, 100, 0, 100)
- mainFrame.Position = UDim2.new(0, 0, 0, 0)
- mainFrame.BackgroundColor3 = Color3.new(1, 1, 1)
- mainFrame.Active = true
- mainFrame.Draggable = true
- local title = Instance.new("TextLabel", mainFrame)
- title.Size = UDim2.new(0, 100, 0, 20)
- title.Name = "My title"
- title.BackgroundColor3 = Color3.new(1, 1, 1)
- title.Position = UDim2.new(0, 0, 0, 0)
- title.Text = "Example GUI toggle"
- title.TextScaled = true
- title.Font = Enum.Font.Code
- -- Function Toggle
- local isOn = false
- local toggle = Instance.new("TextButton", mainFrame)
- toggle.Size = UDim2.new(0, 100, 0, 30)
- toggle.Position = UDim2.new(0, 0, 0, 30)
- toggle.Name = "My toggle"
- toggle.BackgroundColor3 = Color3.new(1, 1, 1)
- toggle.Text = "Not Toggled"
- toggle.TextScaled = true
- toggle.MouseButton1Click:Connect(function()
- isOn = not isOn
- if isOn then
- toggle.Text = "Toggled"
- while isOn do
- wait(1)
- print("hello world")
- if not isOn then
- toggle.Text = "Not Toggled"
- break
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement