OP V4 FLOAT GUI
Key RequiredUniversal

OP V4 FLOAT GUI

Universal Scriptcastledot123castledot123 3.4K views 287 executesUpdated Jun 22, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•121 lines (3869 chars)
-- Create the initial GUI
local player = game.Players.LocalPlayer
local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
screenGui.Name = "FlyGui"

local background = Instance.new("Frame", screenGui)
background.Size = UDim2.new(0, 300, 0, 150) -- Size of the draggable GUI
background.BackgroundColor3 = Color3.fromRGB(128, 0, 128) -- Purple
background.BackgroundTransparency = 0.3
background.Position = UDim2.new(0.5, -150, 0.5, -75) -- Initial position

-- Variables for dragging the GUI
local dragging = false
local dragInput, startPos, startDragPos

-- Make the background draggable (mouse & touch input)
local function beginDrag(input)
	dragging = true
	startPos = background.Position
	startDragPos = input.Position
	input.Consumed = true
end

local function updateDrag(input)
	if dragging then
		local delta = input.Position - startDragPos
		background.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
	end
end

local function endDrag(input)
	dragging = false
end

-- Connect dragging events for both mouse and touch input
background.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		beginDrag(input)
	end
end)

background.InputChanged:Connect(function(input)
	if (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) and dragging then
		updateDrag(input)
	end
end)

background.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		endDrag(input)
	end
end)

-- Toggle Fly Button
local button = Instance.new("TextButton", background)
button.Size = UDim2.new(0, 200, 0, 50)
button.Position = UDim2.new(0.5, -100, 0.5, -25)
button.Text = "Toggle Fly"
button.BackgroundColor3 = Color3.fromRGB(200, 100, 255)
button.TextScaled = true
button.Font = Enum.Font.SourceSansBold
button.TextColor3 = Color3.new(1, 1, 1)

-- Close Button
local closeButton = Instance.new("TextButton", background)
closeButton.Size = UDim2.new(0, 40, 0, 40)
closeButton.Position = UDim2.new(1, -45, 0, 5)
closeButton.Text = "X"
closeButton.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
closeButton.TextColor3 = Color3.new(1, 1, 1)
closeButton.Font = Enum.Font.SourceSansBold
closeButton.TextScaled = true
closeButton.ZIndex = 2

-- Fly logic
local flying = false
local bodyVel = nil

button.MouseButton1Click:Connect(function()
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

	if not flying then
		-- Start flying
		bodyVel = Instance.new("BodyVelocity")
		bodyVel.Velocity = Vector3.new(0, 50, 0)
		bodyVel.MaxForce = Vector3.new(0, math.huge, 0)
		bodyVel.P = 1250
		bodyVel.Parent = humanoidRootPart
		flying = true
		button.Text = "Unfly"
	else
		-- Stop flying
		if bodyVel then
			bodyVel:Destroy()
		end
		flying = false
		button.Text = "Fly"
	end
end)

-- Close (hide) GUI
closeButton.MouseButton1Click:Connect(function()
	screenGui.Enabled = false -- This hides the GUI instead of destroying it
end)

-- Show Fly GUI button (appears when the GUI is hidden)
local showButton = Instance.new("TextButton", player.PlayerGui)
showButton.Size = UDim2.new(0, 200, 0, 50)
showButton.Position = UDim2.new(0.5, -100, 0.5, 100)
showButton.Text = "Show Fly GUI"
showButton.BackgroundColor3 = Color3.fromRGB(100, 255, 100)
showButton.TextScaled = true
showButton.Font = Enum.Font.SourceSansBold
showButton.TextColor3 = Color3.new(1, 1, 1)

-- Show the GUI again when this button is tapped
showButton.MouseButton1Click:Connect(function()
	screenGui.Enabled = true -- Show the GUI again
	showButton:Destroy()  -- Remove the "Show Fly GUI" button after it's used
end)

Features & Information

click fly to float

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts