ability wars loop tp to portal and player
Key RequiredUniversal

ability wars loop tp to portal and player

Universal Scriptthatonecoolguythatonecoolguy 3.6K views 1.3K executesUpdated Nov 1, 2025
Unrated
00
Lua Script•149 lines (4407 chars)
--// LocalScript in StarterPlayerScripts

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local gui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
gui.Name = "TeleportController"
gui.ResetOnSpawn = false

-- CONFIG
local teleportInterval = 0.3
local inFrontDistance = 2
local isLooping = false
local targetName = nil

-- Create UI
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 200, 0, 150)
frame.Position = UDim2.new(0, 20, 0, 200)
frame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
frame.BorderSizePixel = 0
frame.Parent = gui

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, 0, 0, 25)
title.BackgroundTransparency = 1
title.Text = "Teleport Controls"
title.TextColor3 = Color3.new(1, 1, 1)
title.Font = Enum.Font.SourceSansBold
title.TextSize = 18
title.Parent = frame

local targetBox = Instance.new("TextBox")
targetBox.PlaceholderText = "Enter player name"
targetBox.Size = UDim2.new(1, -20, 0, 25)
targetBox.Position = UDim2.new(0, 10, 0, 35)
targetBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
targetBox.TextColor3 = Color3.new(1, 1, 1)
targetBox.Text = ""
targetBox.ClearTextOnFocus = false
targetBox.Parent = frame

local toggleButton = Instance.new("TextButton")
toggleButton.Size = UDim2.new(1, -20, 0, 30)
toggleButton.Position = UDim2.new(0, 10, 0, 70)
toggleButton.BackgroundColor3 = Color3.fromRGB(0, 120, 255)
toggleButton.TextColor3 = Color3.new(1, 1, 1)
toggleButton.Text = "Start Teleport"
toggleButton.Font = Enum.Font.SourceSansBold
toggleButton.TextSize = 16
toggleButton.Parent = frame

local statusLabel = Instance.new("TextLabel")
statusLabel.Size = UDim2.new(1, -20, 0, 25)
statusLabel.Position = UDim2.new(0, 10, 0, 110)
statusLabel.BackgroundTransparency = 1
statusLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
statusLabel.Text = "Status: Idle"
statusLabel.Font = Enum.Font.SourceSans
statusLabel.TextSize = 16
statusLabel.Parent = frame

-- Autofill behavior
targetBox:GetPropertyChangedSignal("Text"):Connect(function()
	local input = targetBox.Text:lower()
	for _, plr in pairs(Players:GetPlayers()) do
		if plr.Name:lower():sub(1, #input) == input then
			targetBox.Text = plr.Name
			targetBox.CursorPosition = #targetBox.Text + 1
			break
		end
	end
end)

-- Core teleport logic
local teleportLoopRunning = false
local currentCharacter

local function startTeleportLoop(char)
	if teleportLoopRunning then return end
	teleportLoopRunning = true
	statusLabel.Text = "Status: Looping..."

	local root = char:WaitForChild("HumanoidRootPart", 5) or char:WaitForChild("Torso", 5)
	if not root then return end

	while teleportLoopRunning and char.Parent and isLooping do
		local targetPlayer = Players:FindFirstChild(targetName)
		if targetPlayer and targetPlayer.Character and targetPlayer.Character:FindFirstChild("HumanoidRootPart") then
			local targetRoot = targetPlayer.Character.HumanoidRootPart
			local frontPos = targetRoot.Position + (targetRoot.CFrame.LookVector * inFrontDistance)
			root.CFrame = CFrame.new(frontPos, targetRoot.Position)
		end
		task.wait(teleportInterval)
	end

	statusLabel.Text = "Status: Idle"
end

local function onCharacterAdded(char)
	currentCharacter = char
	task.wait(0.25)
	teleportLoopRunning = false

	-- Teleport to Portal
	local portal = workspace:WaitForChild("Portals"):WaitForChild("Arena Frame"):WaitForChild("Portal")
	local root = char:WaitForChild("HumanoidRootPart", 5) or char:WaitForChild("Torso", 5)
	if root then
		root.CFrame = portal.CFrame + Vector3.new(0, 3, 0)
	end

	task.wait(0.3)

	-- Restart loop if active
	if isLooping and targetName then
		task.spawn(function()
			startTeleportLoop(char)
		end)
	end
end

player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
	onCharacterAdded(player.Character)
end

-- Button logic
toggleButton.MouseButton1Click:Connect(function()
	if not targetBox.Text or targetBox.Text == "" then
		statusLabel.Text = "Status: No target!"
		return
	end

	targetName = targetBox.Text

	isLooping = not isLooping
	if isLooping then
		toggleButton.Text = "Stop Teleport"
		toggleButton.BackgroundColor3 = Color3.fromRGB(255, 60, 60)
		if currentCharacter then
			task.spawn(function()
				startTeleportLoop(currentCharacter)
			end)
		end
	else
		toggleButton.Text = "Start Teleport"
		toggleButton.BackgroundColor3 = Color3.fromRGB(0, 120, 255)
		teleportLoopRunning = false
	end
end)

Features & Information

test

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts