Item and safe teleporter
Key Required

Item and safe teleporter

Project TransfurFlipflopFlipflop 6.3K views 208 executesUpdated Feb 25, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•271 lines (9265 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- --- UI Setup ---

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "ModelTeleportUI"
screenGui.Parent = playerGui
screenGui.ResetOnSpawn = false

local frame = Instance.new("Frame")
frame.Name = "MainFrame"
frame.Size = UDim2.new(0, 250, 0, 350)
frame.Position = UDim2.new(0.5, -125, 0.5, -175)
frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
frame.BorderSizePixel = 0
frame.Active = true
frame.Visible = true
frame.Parent = screenGui

local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -50, 0, 30)
titleLabel.Position = UDim2.new(0, 0, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextSize = 18
titleLabel.TextColor3 = Color3.new(1, 1, 1)
titleLabel.Text = "Teleport to Item"
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = frame

local minimizeButton = Instance.new("TextButton")
minimizeButton.Size = UDim2.new(0, 20, 0, 20)
minimizeButton.Position = UDim2.new(1, -45, 0, 5)
minimizeButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
minimizeButton.Text = "_"
minimizeButton.Font = Enum.Font.Code
minimizeButton.TextSize = 18
minimizeButton.TextColor3 = Color3.new(1,1,1)
minimizeButton.Parent = frame

local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0, 20, 0, 20)
closeButton.Position = UDim2.new(1, -25, 0, 5)
closeButton.BackgroundColor3 = Color3.fromRGB(180, 40, 40)
closeButton.Text = "X"
closeButton.Font = Enum.Font.Code
closeButton.TextSize = 18
closeButton.TextColor3 = Color3.new(1, 1, 1)
closeButton.Parent = frame

local searchBox = Instance.new("TextBox")
searchBox.Size = UDim2.new(1, -10, 0, 30)
searchBox.Position = UDim2.new(0, 5, 0, 30)
searchBox.BackgroundTransparency = 0
searchBox.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
searchBox.Font = Enum.Font.GothamMedium
searchBox.TextSize = 14
searchBox.TextColor3 = Color3.new(1, 1, 1)
searchBox.PlaceholderText = "Search..."
searchBox.ClearTextOnFocus = false
searchBox.Text = ""
searchBox.Name = "SearchBox"
searchBox.Parent = frame

local scrollingFrame = Instance.new("ScrollingFrame")
scrollingFrame.Size = UDim2.new(1, 0, 0, 180)
scrollingFrame.Position = UDim2.new(0, 0, 0, 65)
scrollingFrame.BackgroundTransparency = 1
scrollingFrame.ScrollBarThickness = 8
scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
scrollingFrame.Parent = frame
scrollingFrame.ScrollingDirection = Enum.ScrollingDirection.Y
scrollingFrame.VerticalScrollBarPosition = Enum.VerticalScrollBarPosition.Right
scrollingFrame.ClipsDescendants = true

local openButton = Instance.new("TextButton")
openButton.Size = UDim2.new(0, 50, 0, 30)
openButton.Position = UDim2.new(1, -60, 1, -40)
openButton.BackgroundColor3 = Color3.fromRGB(40, 120, 40)
openButton.Text = "OPEN"
openButton.Font = Enum.Font.GothamBold
openButton.TextSize = 14
openButton.TextColor3 = Color3.new(1, 1, 1)
openButton.Parent = screenGui
openButton.Visible = false

-- --- Teleport to Random Safe Button ---

local teleportButton = Instance.new("TextButton")
teleportButton.Size = UDim2.new(0, 180, 0, 30)  -- Wider button
teleportButton.Position = UDim2.new(0.5, -90, 1, -40)  -- Centered at the bottom
teleportButton.BackgroundColor3 = Color3.fromRGB(40, 160, 40)  -- Green
teleportButton.Font = Enum.Font.GothamBold
teleportButton.TextSize = 14
teleportButton.TextColor3 = Color3.new(1, 1, 1)
teleportButton.Text = "Teleport to Random Safe"
teleportButton.Name = "TeleportButton"
teleportButton.Parent = frame


-- --- Functionality ---

local function populateScrollingFrame(searchText)
    searchText = searchText:lower()

    -- Clear existing buttons
    for _, child in ipairs(scrollingFrame:GetChildren()) do
        if child:IsA("TextButton") then
            child:Destroy()
        end
    end

    local buttonHeight = 25
    local yOffset = 0

    local spawnPoints = workspace.Environment:FindFirstChild("WorldModelSpawns")
    if not spawnPoints then return end
    local lootSpawnPoints = spawnPoints:FindFirstChild("LootSpawnPoints")
    if not lootSpawnPoints then return end

    for _, model in ipairs(lootSpawnPoints:GetDescendants()) do
        if model:IsA("Model") then
            local modelNameLower = model.Name:lower()
            if string.find(modelNameLower, searchText) then
                local modelButton = Instance.new("TextButton")
                modelButton.Size = UDim2.new(1, 0, 0, buttonHeight)
                modelButton.Position = UDim2.new(0, 0, 0, yOffset)
                modelButton.BackgroundTransparency = 0
                modelButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
                modelButton.Font = Enum.Font.GothamMedium
                modelButton.TextSize = 14
                modelButton.TextColor3 = Color3.new(1, 1, 1)
                modelButton.Text = model.Name
                modelButton.TextXAlignment = Enum.TextXAlignment.Left
                modelButton.Parent = scrollingFrame
                modelButton.Name = "ModelButton_" .. model.Name

                modelButton.MouseButton1Click:Connect(function()
                    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
                        local modelCFrame, _ = model:GetBoundingBox()
                        if modelCFrame then
                            player.Character:PivotTo(modelCFrame + Vector3.new(0, 5, 0))
                        end
                    end
                end)

                yOffset = yOffset + buttonHeight
            end
        end
    end

    scrollingFrame.CanvasSize = UDim2.new(0, 0, 0, yOffset)
end


-- --- Teleport to Safe Logic ---

local function teleportToRandomSafe()
    if not (player.Character and player.Character:FindFirstChild("HumanoidRootPart")) then
        warn("Character or HumanoidRootPart not found")
        return  -- Exit if character isn't loaded
    end

    -- 1. Gather large safes
    local largeSafes = {}
    for _, item in ipairs(workspace.Environment.Interactable.Misc:GetDescendants()) do
        if item:IsA("Model") and item.Name == "__BasicLargeSafe" and item:FindFirstChild("BasePart") then
            table.insert(largeSafes, item)
        end
    end

    -- 2. If large safes exist, choose from them
    local safesToUse = largeSafes
    if #safesToUse == 0 then  -- If no large safes...
        -- 3. Gather small safes (only if no large safes)
        local smallSafes = {}
        for _, item in ipairs(workspace.Environment.Interactable.Misc:GetDescendants()) do
          if item:IsA("Model") and item.Name == "__BasicSmallSafe" and item:FindFirstChild("BasePart") then
                table.insert(smallSafes, item)
            end
        end
        safesToUse = smallSafes  -- Use small safes instead
    end

    -- 4. Check if any safes were found (of either type)
    if #safesToUse > 0 then
        -- 5. Choose a random safe
        local randomIndex = math.random(1, #safesToUse)
        local randomSafe = safesToUse[randomIndex]

        -- 6. Teleport the player to the safe's BasePart
        local basePart = randomSafe:FindFirstChild("BasePart")
        if basePart then
             local safeCFrame, safeSize = randomSafe:GetBoundingBox()
            player.Character:PivotTo(safeCFrame)
        else
            warn("Selected safe has no BasePart:", randomSafe.Name)
        end
    else
        warn("No safes found!")
    end
end

-- --- Event Handlers ---

teleportButton.MouseButton1Click:Connect(teleportToRandomSafe)  -- Connect to the new function


minimizeButton.MouseButton1Click:Connect(function()
    frame.Visible = false
    openButton.Visible = true
end)

closeButton.MouseButton1Click:Connect(function()
    screenGui:Destroy()
end)

openButton.MouseButton1Click:Connect(function()
    frame.Visible = true
    openButton.Visible = false
end)


-- Initial population (show all models initially)
populateScrollingFrame("")

-- Search box event
searchBox:GetPropertyChangedSignal("Text"):Connect(function()
    populateScrollingFrame(searchBox.Text)
end)

-- --- Dragging Functionality ---
local UserInputService = game:GetService("UserInputService")
local dragging
local dragInput
local dragStart
local startPos

local function updateInput(input)
	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

frame.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		dragging = true
		dragStart = input.Position
		startPos = frame.Position

		input.Changed:Connect(function()
			if input.UserInputState == Enum.UserInputState.End then
				dragging = false
			end
		end)
	end
end)

frame.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 dragging then
		updateInput(input)
	end
end)

Features & Information

(sometimes it will not load items, just wait and keep searching and clearing the search bar until items pop up) it will prioritize the larger safes before going to the smaller safes when clicking the teleport to random safes click an item or search for it to teleport to it

Community Comments (2)

FlipflopFlipflopMar 1, 2025(edited)

this game has NO scripts so I triedto make one

canjohn509canjohn509Jun 3, 2025

Muahahahha it's time to make chaos to these ubnormal