Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local plr = game:GetService("Players").LocalPlayer
- local mouse = plr:GetMouse()
- local UIS = game:GetService("UserInputService")
- local teleporting = false
- local dragging = false
- local dragStart = nil
- local startPos = nil
- local teleportEnabled = false -- Keep track of teleportation status
- -- Function to find a player by partial username or display name
- local function findPlayerByPartialName(partialName)
- local partialLower = string.lower(partialName) -- Case insensitive match
- for _, player in pairs(game:GetService("Players"):GetPlayers()) do
- -- Check if either the player's Username or DisplayName contains the partialName
- if string.find(string.lower(player.Name), partialLower) or string.find(string.lower(player.DisplayName), partialLower) then
- return player -- Return the first player that matches
- end
- end
- return nil -- Return nil if no matching player is found
- end
- -- Function to check for a safe height and avoid collision
- local function getSafeHeight(position)
- local raycastResult = workspace:Raycast(position, Vector3.new(0, -50, 0)) -- Raycast downward to check for ground
- if raycastResult then
- return raycastResult.Position.Y + 5 -- Add a small offset above the ground to prevent clipping
- else
- return position.Y -- Return the original height if no ground is found
- end
- end
- -- Function to check if the destination position is clear (not colliding with objects)
- local function isPositionClear(position)
- local raycastResult = workspace:Raycast(position, Vector3.new(0, 5, 0)) -- Cast ray upwards to check for collisions
- return raycastResult == nil -- If there's no hit, the position is clear
- end
- -- Teleportation when pressing 'E'
- UIS.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.KeyCode == Enum.KeyCode.E and teleportEnabled and not teleporting then
- teleporting = true
- local mousePos = mouse.Hit.p
- -- Adjust the position to a safe height
- local adjustedPos = getSafeHeight(mousePos)
- -- Check if the position is clear
- if isPositionClear(Vector3.new(mousePos.X, adjustedPos, mousePos.Z)) then
- -- Teleport to the point clicked
- if plr.Character then
- local hrp = plr.Character:FindFirstChild("HumanoidRootPart")
- if hrp then
- hrp.CFrame = CFrame.new(Vector3.new(mousePos.X, adjustedPos, mousePos.Z))
- end
- end
- else
- print("Clicked position is blocked. Teleportation canceled.")
- end
- teleporting = false -- Reset teleporting state
- end
- end)
- -- GUI Creation (updated with a smaller frame and larger fonts)
- local gui = Instance.new("ScreenGui", plr:WaitForChild("PlayerGui"))
- gui.Name = "ModernUI_V2"
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 350, 0, 250) -- Smaller size of the GUI (compared to before)
- frame.Position = UDim2.new(0.5, -175, 0.5, -125)
- frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- frame.BorderSizePixel = 0
- frame.AnchorPoint = Vector2.new(0.5, 0.5)
- local frameCorner = Instance.new("UICorner", frame)
- frameCorner.CornerRadius = UDim.new(0.05, 0) -- Subtle rounded corners
- -- Title Bar (Updated to V2)
- local title = Instance.new("TextLabel", frame)
- title.Size = UDim2.new(1, 0, 0.15, 0)
- title.Position = UDim2.new(0, 0, 0, 0)
- title.BackgroundTransparency = 1
- title.Text = "Made by 666team6666 V2"
- title.TextColor3 = Color3.fromRGB(255, 255, 255)
- title.Font = Enum.Font.GothamBold
- title.TextSize = 18 -- Increased font size
- title.TextStrokeTransparency = 0.5
- title.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- -- Textbox for Username Input
- local textbox = Instance.new("TextBox", frame)
- textbox.Size = UDim2.new(0.8, 0, 0.15, 0)
- textbox.Position = UDim2.new(0.1, 0, 0.2, 0)
- textbox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
- textbox.Text = ""
- textbox.PlaceholderText = "Enter Username (Partial OK)"
- textbox.Font = Enum.Font.Gotham
- textbox.TextColor3 = Color3.fromRGB(255, 255, 255)
- textbox.TextSize = 16 -- Increased font size for better readability
- textbox.TextStrokeTransparency = 0.8
- textbox.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- local textboxCorner = Instance.new("UICorner", textbox)
- textboxCorner.CornerRadius = UDim.new(0.1, 0) -- Rounded corners for textbox
- -- Select Button (Dark Green by Default)
- local selectButton = Instance.new("TextButton", frame)
- selectButton.Size = UDim2.new(0.8, 0, 0.15, 0)
- selectButton.Position = UDim2.new(0.1, 0, 0.4, 0)
- selectButton.BackgroundColor3 = Color3.fromRGB(0, 75, 0) -- Dark Green color (solid)
- selectButton.Text = "Select (Teleport)"
- selectButton.Font = Enum.Font.Gotham
- selectButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- selectButton.TextSize = 16 -- Increased font size
- selectButton.TextStrokeTransparency = 0.8
- selectButton.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- local selectCorner = Instance.new("UICorner", selectButton)
- selectCorner.CornerRadius = UDim.new(0.1, 0) -- Rounded corners for button
- -- Enable Button (True Dark Blue)
- local enable = Instance.new("TextButton", frame)
- enable.Size = UDim2.new(0.8, 0, 0.15, 0)
- enable.Position = UDim2.new(0.1, 0, 0.6, 0)
- enable.BackgroundColor3 = Color3.fromRGB(0, 0, 100) -- Dark Blue
- enable.Text = "Enable Teleportation"
- enable.Font = Enum.Font.Gotham
- enable.TextColor3 = Color3.fromRGB(255, 255, 255)
- enable.TextSize = 16 -- Increased font size
- enable.TextStrokeTransparency = 0.8
- enable.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- local enableCorner = Instance.new("UICorner", enable)
- enableCorner.CornerRadius = UDim.new(0.1, 0) -- Rounded corners for the button
- -- Disable Button (True Dark Red)
- local disable = Instance.new("TextButton", frame)
- disable.Size = UDim2.new(0.8, 0, 0.15, 0)
- disable.Position = UDim2.new(0.1, 0, 0.8, 0)
- disable.BackgroundColor3 = Color3.fromRGB(100, 0, 0) -- Dark Red
- disable.Text = "Disable Teleportation"
- disable.Font = Enum.Font.Gotham
- disable.TextColor3 = Color3.fromRGB(255, 255, 255)
- disable.TextSize = 16 -- Increased font size
- disable.TextStrokeTransparency = 0.8
- disable.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- local disableCorner = Instance.new("UICorner", disable)
- disableCorner.CornerRadius = UDim.new(0.1, 0) -- Rounded corners for the button
- -- Close Button (Positioned top right inside the frame, smaller and interactive)
- local close = Instance.new("TextButton", frame)
- close.Size = UDim2.new(0.1, 0, 0.1, 0) -- Smaller size for the close button
- close.Position = UDim2.new(1, -40, 0, 10) -- Top-right corner inside the frame
- close.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
- close.Text = "X"
- close.Font = Enum.Font.GothamBold
- close.TextColor3 = Color3.fromRGB(255, 255, 255)
- close.TextSize = 18 -- Increased font size for the close button
- close.TextStrokeTransparency = 0.8
- close.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
- local closeCorner = Instance.new("UICorner", close)
- closeCorner.CornerRadius = UDim.new(0.2, 0)
- -- Close button function (to destroy the GUI)
- close.MouseButton1Click:Connect(function()
- gui:Destroy() -- Close the GUI
- end)
- -- Close button hover interaction
- close.MouseEnter:Connect(function()
- close.BackgroundColor3 = Color3.fromRGB(255, 0, 0) -- Turn red when hovered
- end)
- close.MouseLeave:Connect(function()
- close.BackgroundColor3 = Color3.fromRGB(45, 45, 45) -- Return to original color when not hovered
- end)
- -- Teleport to Player based on Username or Display Name
- selectButton.MouseButton1Click:Connect(function()
- local username = textbox.Text
- local targetPlayer = findPlayerByPartialName(username) -- Check for partial username or display name
- if targetPlayer and targetPlayer.Character then
- local targetHRP = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
- if targetHRP then
- local targetPos = targetHRP.Position
- -- Adjust to safe height if necessary
- local adjustedHeight = getSafeHeight(targetPos)
- targetPos = Vector3.new(targetPos.X, adjustedHeight, targetPos.Z)
- -- Ensure position is clear
- if isPositionClear(targetPos) then
- -- Teleport to the player
- if plr.Character then
- local hrp = plr.Character:FindFirstChild("HumanoidRootPart")
- if hrp then
- hrp.CFrame = CFrame.new(targetPos)
- end
- end
- else
- print("Target position blocked. Teleportation canceled.")
- end
- end
- else
- print("Player not found.")
- end
- end)
- -- Enable teleportation functionality
- enable.MouseButton1Click:Connect(function()
- teleportEnabled = true -- Enable teleportation
- print("Teleportation enabled.")
- end)
- -- Disable teleportation functionality
- disable.MouseButton1Click:Connect(function()
- teleportEnabled = false -- Disable teleportation
- print("Teleportation disabled.")
- end)
- -- Dragging functionality
- frame.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = true
- dragStart = input.Position
- startPos = frame.Position
- end
- end)
- frame.InputChanged:Connect(function(input)
- if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- local delta = input.Position - dragStart
- frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
- end
- end)
- frame.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = false
- end
- end)
- -- Automatically disable teleportation when the player dies
- plr.CharacterAdded:Connect(function(character)
- teleportEnabled = false -- Disable teleportation when a new character spawns
- end)
- plr.CharacterRemoving:Connect(function(character)
- teleportEnabled = false -- Disable teleportation when the player dies
- end)
Advertisement
Add Comment
Please, Sign In to add comment