Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
3.5 kB
4
Indexable
Never
-- Create a ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

-- Create a Frame to hold the button and script input
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 300, 0, 80)
frame.Position = UDim2.new(0.5, -150, 0.5, -40)
frame.BackgroundTransparency = 0.5
frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
frame.Parent = screenGui

-- Create a TextLabel for script input label
local scriptLabel = Instance.new("TextLabel")
scriptLabel.Size = UDim2.new(1, 0, 0, 20)
scriptLabel.Position = UDim2.new(0, 0, 0, 5)
scriptLabel.BackgroundTransparency = 1
scriptLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
scriptLabel.TextScaled = true
scriptLabel.Font = Enum.Font.SourceSansBold
scriptLabel.Text = "Enter Script:"
scriptLabel.Parent = frame

-- Create a TextBox for script input
local scriptTextBox = Instance.new("TextBox")
scriptTextBox.Size = UDim2.new(1, -10, 0, 25)
scriptTextBox.Position = UDim2.new(0, 5, 0, 30)
scriptTextBox.BackgroundTransparency = 0.8
scriptTextBox.TextColor3 = Color3.fromRGB(0, 0, 0)
scriptTextBox.TextScaled = true
scriptTextBox.Font = Enum.Font.SourceSans
scriptTextBox.Parent = frame

-- Create a Frame to hold the button and status label
local buttonFrame = Instance.new("Frame")
buttonFrame.Size = UDim2.new(0, 100, 0, 30)
buttonFrame.Position = UDim2.new(0.5, -50, 0.5, 15)
buttonFrame.BackgroundTransparency = 0.5
buttonFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
buttonFrame.Parent = frame

-- Create a TextLabel to display the button's status
local statusLabel = Instance.new("TextLabel")
statusLabel.Size = UDim2.new(1, 0, 1, 0)
statusLabel.BackgroundTransparency = 1
statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
statusLabel.TextScaled = true
statusLabel.Font = Enum.Font.SourceSansBold
statusLabel.Text = "OFF"
statusLabel.Parent = buttonFrame

-- Create a BooleanValue to track the button's state
local buttonState = Instance.new("BoolValue")
buttonState.Name = "ButtonState"
buttonState.Value = false
buttonState.Parent = buttonFrame

-- Create the button
local button = Instance.new("TextButton")
button.Size = UDim2.new(1, 0, 1, 0)
button.BackgroundTransparency = 1
button.Text = ""
button.Parent = buttonFrame

-- Create a small "-" button to toggle GUI size
local minimizeButton = Instance.new("TextButton")
minimizeButton.Size = UDim2.new(0, 20, 0, 20)
minimizeButton.Position = UDim2.new(1, -25, 0, 5)
minimizeButton.BackgroundTransparency = 0.5
minimizeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
minimizeButton.Text = "-"
minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
minimizeButton.Font = Enum.Font.SourceSansBold
minimizeButton.TextSize = 14
minimizeButton.Parent = frame

-- Variables to track mouse input
local isDragging = false
local dragStartPos
local dragStartOffset

-- Function to handle mouse input
local function handleDrag(input)
	if isDragging then
		local delta = input.Position - dragStartPos
		frame.Position = UDim2.new(
			dragStartOffset.X.Scale,
			dragStartOffset.X.Offset + delta.X,
			dragStartOffset.Y.Scale,
			dragStartOffset.Y.Offset + delta.Y
		)
	end
end

-- Function to start dragging
local function startDrag(input)
	isDragging = true
	dragStartPos = input.Position
	dragStartOffset = frame.Position - UDim2.new(0, dragStartPos.X, 0, dragStartPos.Y)
end

-- Function to stop dragging
local function stopDrag()
	isDragging = false
end

-- Connect events to handle dragging
frame.InputBegan:Connect(function(input)
	if
Leave a Comment