Back to Scripts
*EPUH PLAYER LOCATER AND TP
ScriptBlox
Universal
Free
Game: Universal Script 📌
118
Views
0
Likes
0
Dislikes
jaybirdmillion
offline
Features
this lets you spectate players on your server and teleport to them
Script Code
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local CurrentCamera = workspace.CurrentCamera
local spectating = false
local spectatedPlayer = nil
-- Create ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "SpectateGui"
screenGui.ResetOnSpawn = false
screenGui.Parent = PlayerGui
-- Main Frame
local mainFrame = Instance.new("Frame")
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(0, 300, 0, 400)
mainFrame.Position = UDim2.new(0, 20, 0.5, -200)
mainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
mainFrame.BorderSizePixel = 0
mainFrame.Parent = screenGui
-- Add UICorner for rounded edges
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 10)
corner.Parent = mainFrame
-- Title Label
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, 0, 0, 40)
titleLabel.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
titleLabel.BorderSizePixel = 0
titleLabel.Text = "Player Spectator"
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.TextSize = 20
titleLabel.Font = Enum.Font.GothamBold
titleLabel.Parent = mainFrame
local titleCorner = Instance.new("UICorner")
titleCorner.CornerRadius = UDim.new(0, 10)
titleCorner.Parent = titleLabel
-- Close Button
local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0, 30, 0, 30)
closeButton.Position = UDim2.new(1, -35, 0, 5)
closeButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
closeButton.BorderSizePixel = 0
closeButton.Text = "X"
closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
closeButton.TextSize = 18
closeButton.Font = Enum.Font.GothamBold
closeButton.Parent = mainFrame
local closeCorner = Instance.new("UICorner")
closeCorner.CornerRadius = UDim.new(0, 5)
closeCorner.Parent = closeButton
-- ScrollingFrame for player list
local playerList = Instance.new("ScrollingFrame")
playerList.Size = UDim2.new(1, -20, 1, -100)
playerList.Position = UDim2.new(0, 10, 0, 50)
playerList.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
playerList.BorderSizePixel = 0
playerList.ScrollBarThickness = 6
playerList.Parent = mainFrame
local listCorner = Instance.new("UICorner")
listCorner.CornerRadius = UDim.new(0, 8)
listCorner.Parent = playerList
-- UIListLayout for organizing players
local listLayout = Instance.new("UIListLayout")
listLayout.SortOrder = Enum.SortOrder.Name
listLayout.Padding = UDim.new(0, 5)
listLayout.Parent = playerList
-- Stop Spectating Button
local stopButton = Instance.new("TextButton")
stopButton.Size = UDim2.new(1, -20, 0, 35)
stopButton.Position = UDim2.new(0, 10, 1, -45)
stopButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
stopButton.BorderSizePixel = 0
stopButton.Text = "Stop Spectating"
stopButton.TextColor3 = Color3.fromRGB(255, 255, 255)
stopButton.TextSize = 16
stopButton.Font = Enum.Font.GothamBold
stopButton.Visible = false
stopButton.Parent = mainFrame
local stopCorner = Instance.new("UICorner")
stopCorner.CornerRadius = UDim.new(0, 8)
stopCorner.Parent = stopButton
-- Function to stop spectating
local function stopSpectating()
if spectating then
spectating = false
spectatedPlayer = nil
CurrentCamera.CameraSubject = LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("Humanoid")
CurrentCamera.CameraType = Enum.CameraType.Custom
stopButton.Visible = false
end
end
-- Function to spectate a player
local function spectatePlayer(player)
if player == LocalPlayer then return end
stopSpectating()
if player.Character and player.Character:FindFirstChild("Humanoid") then
spectating = true
spectatedPlayer = player
CurrentCamera.CameraSubject = player.Character.Humanoid
stopButton.Visible = true
end
end
-- Function to teleport to player
local function teleportToPlayer(player)
if player == LocalPlayer then return end
local character = LocalPlayer.Character
local targetCharacter = player.Character
if character and targetCharacter then
local hrp = character:FindFirstChild("HumanoidRootPart")
local targetHrp = targetCharacter:FindFirstChild("HumanoidRootPart")
if hrp and targetHrp then
hrp.CFrame = targetHrp.CFrame + Vector3.new(3, 0, 0)
stopSpectating()
end
end
end
-- Function to create player button
local function createPlayerButton(player)
local playerFrame = Instance.new("Frame")
playerFrame.Name = player.Name
playerFrame.Size = UDim2.new(1, -10, 0, 50)
playerFrame.BackgroundColor3 = Color3.fromRGB(55, 55, 55)
playerFrame.BorderSizePixel = 0
playerFrame.Parent = playerList
local frameCorner = Instance.new("UICorner")
frameCorner.CornerRadius = UDim.new(0, 6)
frameCorner.Parent = playerFrame
local nameLabel = Instance.new("TextLabel")
nameLabel.Size = UDim2.new(1, -110, 1, 0)
nameLabel.Position = UDim2.new(0, 10, 0, 0)
nameLabel.BackgroundTransparency = 1
nameLabel.Text = player.Name
nameLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
nameLabel.TextSize = 14
nameLabel.Font = Enum.Font.Gotham
nameLabel.TextXAlignment = Enum.TextXAlignment.Left
nameLabel.Parent = playerFrame
local spectateBtn = Instance.new("TextButton")
spectateBtn.Size = UDim2.new(0, 45, 0, 30)
spectateBtn.Position = UDim2.new(1, -95, 0.5, -15)
spectateBtn.BackgroundColor3 = Color3.fromRGB(50, 150, 250)
spectateBtn.BorderSizePixel = 0
spectateBtn.Text = "👁️"
spectateBtn.TextSize = 18
spectateBtn.Parent = playerFrame
local specCorner = Instance.new("UICorner")
specCorner.CornerRadius = UDim.new(0, 5)
specCorner.Parent = spectateBtn
local teleportBtn = Instance.new("TextButton")
teleportBtn.Size = UDim2.new(0, 45, 0, 30)
teleportBtn.Position = UDim2.new(1, -45, 0.5, -15)
teleportBtn.BackgroundColor3 = Color3.fromRGB(50, 200, 100)
teleportBtn.BorderSizePixel = 0
teleportBtn.Text = "📍"
teleportBtn.TextSize = 18
teleportBtn.Parent = playerFrame
local tpCorner = Instance.new("UICorner")
tpCorner.CornerRadius = UDim.new(0, 5)
tpCorner.Parent = teleportBtn
spectateBtn.MouseButton1Click:Connect(function()
spectatePlayer(player)
end)
teleportBtn.MouseButton1Click:Connect(function()
teleportToPlayer(player)
end)
end
-- Function to update player list
local function updatePlayerList()
for _, child in pairs(playerList:GetChildren()) do
if child:IsA("Frame") then
child:Destroy()
end
end
for _, player in pairs(Players:GetPlayers()) do
if player ~= LocalPlayer then
createPlayerButton(player)
end
end
playerList.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y + 10)
end
-- Update list when players join or leave
Players.PlayerAdded:Connect(updatePlayerList)
Players.PlayerRemoving:Connect(function(player)
if spectatedPlayer == player then
stopSpectating()
end
updatePlayerList()
end)
-- Close button functionality
closeButton.MouseButton1Click:Connect(function()
mainFrame.Visible = not mainFrame.Visible
if not mainFrame.Visible then
stopSpectating()
end
end)
-- Stop spectating button functionality
stopButton.MouseButton1Click:Connect(function()
stopSpectating()
end)
-- Make frame draggable (PC and Mobile)
local UserInputService = game:GetService("UserInputService")
local dragging = false
local dragInput, dragStart, startPos
local function updateDrag(input)
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
titleLabel.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or
input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = mainFrame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
titleLabel.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
updateDrag(input)
end
end)
-- Initial update
updatePlayerList()
-- Keep updating canvas size
listLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
playerList.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y + 10)
end)
Comments (0)
Please login to comment
Login with Discord
Loading comments...