Click Teleport Universal
Key RequiredUniversal

Click Teleport Universal

Universal ScriptRaaRaaRaaRaa 426 views 602 executesUpdated Mar 7, 2026
5.0/ 5(3 votes)
30100% Positive
Lua Script•228 lines (8072 chars)
-- ដាក់ក្នុង LocalScript នៅ StarterGui

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")

local isTeleportEnabled = false
local isDragging = false
local dragInput, dragStart, startPos

-- [[ ផ្នែកបង្កើត GUI សំខាន់ ]]
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "TeleportControlGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = player:WaitForChild("PlayerGui")

-- Frame សំខាន់
local mainFrame = Instance.new("Frame")
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(0, 200, 0, 100)
mainFrame.Position = UDim2.new(0.5, -100, 0.1, 0) -- លេចឡើងខាងលើបន្តិច
mainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
mainFrame.BorderSizePixel = 0
mainFrame.Parent = screenGui

local mainCorner = Instance.new("UICorner")
mainCorner.CornerRadius = UDim.new(0, 10)
mainCorner.Parent = mainFrame

-- Title
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, 0, 0, 30)
title.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
title.Text = "Teleport System"
title.TextColor3 = Color3.new(1, 1, 1)
title.Font = Enum.Font.GothamBold
title.TextSize = 14
title.Parent = mainFrame

local titleCorner = Instance.new("UICorner")
titleCorner.CornerRadius = UDim.new(0, 10)
titleCorner.Parent = title

local titleFix = Instance.new("Frame")
titleFix.Size = UDim2.new(1, 0, 0, 15)
titleFix.Position = UDim2.new(0, 0, 1, -15)
titleFix.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
titleFix.BorderSizePixel = 0
titleFix.Parent = title

-- ប៊ូតុង Toggle (បើក/បិទ)
local toggleButton = Instance.new("TextButton")
toggleButton.Name = "ToggleBtn"
toggleButton.Size = UDim2.new(0.8, 0, 0, 40)
toggleButton.Position = UDim2.new(0.1, 0, 0, 50)
toggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
toggleButton.Text = "OFF"
toggleButton.TextColor3 = Color3.new(1, 1, 1)
toggleButton.Font = Enum.Font.Gotham
toggleButton.TextSize = 16
toggleButton.Parent = mainFrame

local btnCorner = Instance.new("UICorner")
btnCorner.CornerRadius = UDim.new(0, 8)
btnCorner.Parent = toggleButton

-- [[ ផ្នែកប៊ូតុងសម្រាប់ Teleport (សម្រាប់ Mobile/ដៃ) ]]
local teleportBtn = Instance.new("TextButton")
teleportBtn.Name = "TeleportButton"
teleportBtn.Size = UDim2.new(0, 60, 0, 60)
teleportBtn.Position = UDim2.new(1, -70, 1, -150) -- ស្ថិតនៅជ្រុងខាងស្តាំខាងក្រោម
teleportBtn.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
teleportBtn.Text = "GO"
teleportBtn.TextColor3 = Color3.new(1, 1, 1)
teleportBtn.Font = Enum.Font.GothamBold
teleportBtn.TextSize = 20
teleportBtn.Visible = false -- លាក់វាសិន
teleportBtn.Parent = screenGui

local teleBtnCorner = Instance.new("UICorner")
teleBtnCorner.CornerRadius = UDim.new(1, 0) -- ធ្វើជារង្វង់
teleBtnCorner.Parent = teleportBtn

local teleBtnStroke = Instance.new("UIStroke")
teleBtnStroke.Color = Color3.new(1, 1, 1)
teleBtnStroke.Thickness = 2
teleBtnStroke.Parent = teleportBtn

-- [[ មុខងារ ]]

-- ការអូស GUI សំខាន់
mainFrame.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        isDragging = true
        dragStart = input.Position
        startPos = mainFrame.Position
        input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then isDragging = false end
        end)
    end
end)

mainFrame.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
        dragInput = input
    end
end)

UserInputService.InputChanged:Connect(function(input)
    if input == dragInput and isDragging and mainFrame then
        local delta = input.Position - dragStart
        mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
    end
end)

-- ការអូសប៊ូតុង Teleport (សម្រាប់ Mobile)
local isTeleBtnDragging = false
local teleBtnDragInput, teleBtnDragStart, teleBtnStartPos

teleportBtn.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        -- បើអ្នកចុចយូរ វានឹងអូសបាន បើចុចធម្មតាវានឹង Teleport
        local waitTime = 0.2
        local startTime = tick()
        local moved = false
        
        local connection
        connection = input.Changed:Connect(function()
            if input.UserInputState == Enum.UserInputState.End then
                connection:Disconnect()
                if not moved then
                    -- គ្រាន់តែ Teleport
                    doTeleport()
                end
            end
        end)
        
        -- ត្រួតពិនិត្យមើលថាតែមានការអូសឬអត់
        spawn(function()
            while input.UserInputState == Enum.UserInputState.Begin do
                wait()
                if (input.Position - teleBtnDragStart).Magnitude > 8 then
                    moved = true
                    break
                end
            end
        end)
        
        teleBtnDragStart = input.Position
        teleBtnStartPos = teleportBtn.Position
    end
end)

teleportBtn.InputChanged:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
        teleBtnDragInput = input
    end
end)

-- ធ្វើការអូសប៊ូតុង Teleport
UserInputService.InputChanged:Connect(function(input)
    if input == teleBtnDragInput and teleportBtn.Visible then
        local delta = input.Position - teleBtnDragStart
        teleportBtn.Position = UDim2.new(teleBtnStartPos.X.Scale, teleBtnStartPos.X.Offset + delta.X, teleBtnStartPos.Y.Scale, teleBtnStartPos.Y.Offset + delta.Y)
    end
end)

-- មុខងារ Teleport
local function doTeleport()
    if isTeleportEnabled then
        -- ទាញយកទីតាំង Mouse/Touch
        -- យើងប្រើ UserInputService ដើម្បីទាញយកទីតាំងចុចក្រោយគេ
        local position = UserInputService:GetMouseLocation() -- នេះគឺជា Mouse Position
        local ray = workspace.CurrentCamera:ViewportPointToRay(position.X, position.Y)
        
        local raycastParams = RaycastParams.new()
        raycastParams.FilterType = Enum.RaycastFilterType.Exclude
        raycastParams.FilterDescendantsInstances = {character}
        
        local raycastResult = workspace:Raycast(ray.Origin, ray.Direction * 1000, raycastParams)
        
        if raycastResult then
            if rootPart and rootPart.Parent then
                rootPart.CFrame = CFrame.new(raycastResult.Position + Vector3.new(0, 3, 0))
            end
        else
            -- ប្រសិនបើ Raycast ទទេ ហោះទៅមុខកាមេរ៉ា
            if rootPart and rootPart.Parent then
                rootPart.CFrame = CFrame.new(ray.Origin + ray.Direction * 50)
            end
        end
    end
end

-- ការចុច Mouse Button ខាងស្តាំ (សម្រាប់ PC)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType == Enum.UserInputType.MouseButton2 then
        doTeleport()
    end
end)

-- ប៊ូតុង Toggle
toggleButton.MouseButton1Click:Connect(function()
    isTeleportEnabled = not isTeleportEnabled
    if isTeleportEnabled then
        toggleButton.Text = "ON"
        toggleButton.BackgroundColor3 = Color3.fromRGB(50, 200, 50)
        teleportBtn.Visible = true -- បង្ហាញប៊ូតុងសំរាប់ដៃ
    else
        toggleButton.Text = "OFF"
        toggleButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
        teleportBtn.Visible = false -- លាក់ប៊ូតុងសំរាប់ដៃ
    end
end)

-- Character Respawn handling
player.CharacterAdded:Connect(function(newCharacter)
    character = newCharacter
    humanoid = newCharacter:WaitForChild("Humanoid")
    rootPart = newCharacter:WaitForChild("HumanoidRootPart")
end)

Features & Information

-Click Teleport

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts