-- 创建主屏幕GUI(对所有玩家生效) local Players = game:GetService("Players") local playerGui = nil -- 为每个玩家创建GUI local function createTeleportGUI(player) local playerGui = player:WaitForChild("PlayerGui") local screenGui = Instance.new("ScreenGui") screenGui.Name = "FloatingTeleportBall" screenGui.ResetOnSpawn = false screenGui.Parent = playerGui -- 创建悬浮球(确保在最上层) local ball = Instance.new("TextButton") ball.Name = "Ball" ball.Size = UDim2.new(0, 60, 0, 60) ball.Position = UDim2.new(0, 20, 0, 20) ball.BackgroundColor3 = Color3.new(0, 0, 0) ball.BorderColor3 = Color3.fromRGB(255, 165, 0) ball.BorderSizePixel = 3 ball.AutoButtonColor = false ball.Text = "" ball.Active = true ball.Draggable = true ball.ZIndex = 100 ball.Parent = screenGui -- 悬浮球上的文字 local ballText = Instance.new("TextLabel") ballText.Name = "Text" ballText.Size = UDim2.new(1, 0, 1, 0) ballText.Text = "高地剑斗" ballText.TextColor3 = Color3.new(1, 1, 1) ballText.BackgroundTransparency = 1 ballText.Font = Enum.Font.SourceSansBold ballText.TextSize = 14 ballText.ZIndex = 101 ballText.Parent = ball -- 创建主列表 local listFrame = Instance.new("Frame") listFrame.Name = "ListFrame" listFrame.Size = UDim2.new(0, 300, 0, 500) listFrame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) listFrame.BorderColor3 = Color3.fromRGB(255, 165, 0) listFrame.BorderSizePixel = 2 listFrame.Visible = false listFrame.ZIndex = 10 listFrame.Parent = screenGui -- 列表标题 local title = Instance.new("TextLabel") title.Name = "Title" title.Size = UDim2.new(1, 0, 0, 30) title.Text = "roblox的happyR5000制作此脚本" title.TextColor3 = Color3.new(1, 1, 1) title.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1) title.Font = Enum.Font.SourceSansBold title.TextSize = 16 title.ZIndex = 11 title.Parent = listFrame -- 创建头像 local avatar = Instance.new("ImageLabel") avatar.Name = "Avatar" avatar.Size = UDim2.new(0, 50, 0, 50) avatar.Position = UDim2.new(1, -60, 0, 30) avatar.BackgroundTransparency = 1 avatar.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=happyR5000&width=420&height=420&format=png" avatar.ZIndex = 11 avatar.Parent = listFrame -- 创建滚动框 local scrollFrame = Instance.new("ScrollingFrame") scrollFrame.Name = "ScrollFrame" scrollFrame.Size = UDim2.new(1, -10, 1, -100) scrollFrame.Position = UDim2.new(0, 5, 0, 40) scrollFrame.BackgroundTransparency = 1 scrollFrame.ScrollBarThickness = 8 scrollFrame.CanvasSize = UDim2.new(0, 0, 0, 2000) scrollFrame.ZIndex = 11 scrollFrame.Parent = listFrame -- 传送位置数据 local teleportLocations = { {name = "经典连结剑", position = Vector3.new(12.4, 100.6, 11.7)}, {name = "锈蚀光辉", position = Vector3.new(257.7, 138.4, 344.5)}, {name = "天空匕首", position = Vector3.new(211.5, 141.2, 325.4)}, {name = "封信纸会", position = Vector3.new(-303.7, 274.5, -65.9)}, {name = "裂地剑", position = Vector3.new(-186, 310.8, -301.8)}, {name = "毒刃", position = Vector3.new(219.9, 221.8, 46.9)}, {name = "冰匕首", position = Vector3.new(38.5, 250.8, 326.2)}, {name = "黑暗之心", position = Vector3.new(-155, 61.0, 211.0)}, {name = "光之辉刃", position = Vector3.new(-434, 389.8, 68.0)}, {name = "风之剑", position = Vector3.new(121.4, 637.0, -301.9)}, {name = "幽灵行者", position = Vector3.new(402.7, 20.2, 112.6)}, {name = "烈焰剑", position = Vector3.new(-191.3, 347.8, -156.9)}, {name = "火箭背包", position = Vector3.new(141.5, 466.2, -127.1)}, {name = "回家球", position = Vector3.new(-176, 275.5, -77.5)}, {name = "无敌球", position = Vector3.new(176.1, 137.8, 201.8)}, {name = "医疗包", position = Vector3.new(132.3, 342.6, 87.6)}, {name = "隐形球", position = Vector3.new(-167.1, 471.0, 254.5)}, {name = "额外生命之书1", position = Vector3.new(21.0, 158.2, 216.2)}, {name = "额外血之书2", position = Vector3.new(36.9, 286.6, -133.8)}, {name = "石头药水", position = Vector3.new(121.5, 64.2, -264.0)}, {name = "额外血之书3", position = Vector3.new(21.1, 286.6, -133.8)}, {name = "blox", position = Vector3.new(38.0, 138.2, 318.4)}, {name = "黑暗剑", position = Vector3.new(-53.3, 140.2, 309.0)}, {name = "隐藏地点3", position = Vector3.new(-399.5, 369.8, 68.2)} } -- 死亡点记录存储(每个玩家独立) local deathPoints = {} local maxDeathPoints = 50 -- 状态变量,用于记住其他列表的显示状态 local playerListWasVisible = false local deathListWasVisible = false -- 创建传送按钮 local function createTeleportButtons() scrollFrame:ClearAllChildren() local yOffset = 0 local buttonHeight = 30 local padding = 5 for i, location in ipairs(teleportLocations) do local buttonFrame = Instance.new("Frame") buttonFrame.Name = location.name buttonFrame.Size = UDim2.new(1, -10, 0, buttonHeight) buttonFrame.Position = UDim2.new(0, 5, 0, yOffset) buttonFrame.BackgroundColor3 = Color3.new(0.3, 0.3, 0.3) buttonFrame.BorderSizePixel = 0 buttonFrame.ZIndex = 12 buttonFrame.Parent = scrollFrame local nameLabel = Instance.new("TextLabel") nameLabel.Name = "Name" nameLabel.Size = UDim2.new(0.7, 0, 1, 0) nameLabel.Text = location.name nameLabel.TextColor3 = Color3.new(1, 1, 1) nameLabel.BackgroundTransparency = 1 nameLabel.Font = Enum.Font.SourceSans nameLabel.TextSize = 14 nameLabel.TextXAlignment = Enum.TextXAlignment.Left nameLabel.ZIndex = 13 nameLabel.Parent = buttonFrame local teleportButton = Instance.new("TextButton") teleportButton.Name = "TeleportButton" teleportButton.Size = UDim2.new(0.25, 0, 0.8, 0) teleportButton.Position = UDim2.new(0.75, 0, 0.1, 0) teleportButton.Text = "传送" teleportButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0) teleportButton.TextColor3 = Color3.new(0, 0, 0) teleportButton.Font = Enum.Font.SourceSansBold teleportButton.TextSize = 14 teleportButton.ZIndex = 13 teleportButton.Parent = buttonFrame teleportButton.MouseButton1Click:Connect(function() if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = CFrame.new(location.position) else warn("角色或HumanoidRootPart不存在") end end) yOffset = yOffset + buttonHeight + padding end return yOffset end -- 创建功能按钮 local function createFunctionButtons(yOffset) local buttonHeight = 30 local padding = 5 -- 创建人数按钮 local playerCountButton = Instance.new("TextButton") playerCountButton.Name = "PlayerCountButton" playerCountButton.Size = UDim2.new(1, -10, 0, buttonHeight) playerCountButton.Position = UDim2.new(0, 5, 0, yOffset + 10) playerCountButton.Text = "显示各区域人数" playerCountButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0) playerCountButton.TextColor3 = Color3.new(0, 0, 0) playerCountButton.Font = Enum.Font.SourceSansBold playerCountButton.TextSize = 14 playerCountButton.ZIndex = 13 playerCountButton.Parent = scrollFrame -- 创建死亡点传送按钮 local deathPointButton = Instance.new("TextButton") deathPointButton.Name = "DeathPointButton" deathPointButton.Size = UDim2.new(1, -10, 0, buttonHeight) deathPointButton.Position = UDim2.new(0, 5, 0, yOffset + 50) deathPointButton.Text = "死亡点传送" deathPointButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0) deathPointButton.TextColor3 = Color3.new(0, 0, 0) deathPointButton.Font = Enum.Font.SourceSansBold deathPointButton.TextSize = 14 deathPointButton.ZIndex = 13 deathPointButton.Parent = scrollFrame -- 创建重新加入服务器按钮 local rejoinButton = Instance.new("TextButton") rejoinButton.Name = "RejoinButton" rejoinButton.Size = UDim2.new(1, -10, 0, buttonHeight) rejoinButton.Position = UDim2.new(0, 5, 0, yOffset + 90) rejoinButton.Text = "重新加入服务器" rejoinButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0) rejoinButton.TextColor3 = Color3.new(0, 0, 0) rejoinButton.Font = Enum.Font.SourceSansBold rejoinButton.TextSize = 14 rejoinButton.ZIndex = 13 rejoinButton.Parent = scrollFrame return playerCountButton, deathPointButton, rejoinButton end -- 初始化按钮 local initialYOffset = createTeleportButtons() local playerCountButton, deathPointButton, rejoinButton = createFunctionButtons(initialYOffset) -- 创建玩家列表框架 local playerListFrame = Instance.new("Frame") playerListFrame.Name = "PlayerListFrame" playerListFrame.Size = UDim2.new(0, 250, 0, 400) playerListFrame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) playerListFrame.BorderColor3 = Color3.fromRGB(255, 165, 0) playerListFrame.BorderSizePixel = 2 playerListFrame.Visible = false playerListFrame.ZIndex = 10 playerListFrame.Parent = screenGui local playerListTitle = Instance.new("TextButton") playerListTitle.Name = "Title" playerListTitle.Size = UDim2.new(1, 0, 0, 30) playerListTitle.Text = "各区域人数 - 点击关闭" playerListTitle.TextColor3 = Color3.new(1, 1, 1) playerListTitle.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1) playerListTitle.Font = Enum.Font.SourceSansBold playerListTitle.TextSize = 16 playerListTitle.AutoButtonColor = false playerListTitle.ZIndex = 11 playerListTitle.Parent = playerListFrame local playerListScroll = Instance.new("ScrollingFrame") playerListScroll.Name = "ScrollFrame" playerListScroll.Size = UDim2.new(1, -10, 1, -40) playerListScroll.Position = UDim2.new(0, 5, 0, 35) playerListScroll.BackgroundTransparency = 1 playerListScroll.ScrollBarThickness = 8 playerListScroll.CanvasSize = UDim2.new(0, 0, 0, 1000) playerListScroll.ZIndex = 11 playerListScroll.Parent = playerListFrame -- 创建死亡点列表框架 local deathListFrame = Instance.new("Frame") deathListFrame.Name = "DeathListFrame" deathListFrame.Size = UDim2.new(0, 280, 0, 400) deathListFrame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) deathListFrame.BorderColor3 = Color3.fromRGB(255, 165, 0) deathListFrame.BorderSizePixel = 2 deathListFrame.Visible = false deathListFrame.ZIndex = 10 deathListFrame.Parent = screenGui local deathListTitle = Instance.new("TextButton") deathListTitle.Name = "Title" deathListTitle.Size = UDim2.new(1, 0, 0, 30) deathListTitle.Text = "死亡点记录 - 点击关闭" deathListTitle.TextColor3 = Color3.new(1, 1, 1) deathListTitle.BackgroundColor3 = Color3.new(0.1, 0.1, 0.1) deathListTitle.Font = Enum.Font.SourceSansBold deathListTitle.TextSize = 16 deathListTitle.AutoButtonColor = false deathListTitle.ZIndex = 11 deathListTitle.Parent = deathListFrame local deathListScroll = Instance.new("ScrollingFrame") deathListScroll.Name = "ScrollFrame" deathListScroll.Size = UDim2.new(1, -10, 1, -80) deathListScroll.Position = UDim2.new(0, 5, 0, 35) deathListScroll.BackgroundTransparency = 1 deathListScroll.ScrollBarThickness = 8 deathListScroll.CanvasSize = UDim2.new(0, 0, 0, 1000) deathListScroll.ZIndex = 11 deathListScroll.Parent = deathListFrame -- 清除所有死亡记录按钮 local clearAllDeathsButton = Instance.new("TextButton") clearAllDeathsButton.Name = "ClearAllDeathsButton" clearAllDeathsButton.Size = UDim2.new(1, -10, 0, 30) clearAllDeathsButton.Position = UDim2.new(0, 5, 1, -35) clearAllDeathsButton.Text = "清除所有死亡记录" clearAllDeathsButton.BackgroundColor3 = Color3.fromRGB(255, 100, 100) clearAllDeathsButton.TextColor3 = Color3.new(1, 1, 1) clearAllDeathsButton.Font = Enum.Font.SourceSansBold clearAllDeathsButton.TextSize = 14 clearAllDeathsButton.ZIndex = 11 clearAllDeathsButton.Parent = deathListFrame -- 点击关闭玩家列表 playerListTitle.MouseButton1Click:Connect(function() playerListFrame.Visible = false playerListWasVisible = false end) -- 点击关闭死亡列表 deathListTitle.MouseButton1Click:Connect(function() deathListFrame.Visible = false deathListWasVisible = false end) -- 计算每个位置附近的玩家数量 local function countPlayersNearPosition(position, radius) local count = 0 for _, otherPlayer in ipairs(game:GetService("Players"):GetPlayers()) do if otherPlayer ~= player and otherPlayer.Character then local hrp = otherPlayer.Character:FindFirstChild("HumanoidRootPart") if hrp and (hrp.Position - position).Magnitude <= radius then count = count + 1 end end end return count end -- 更新玩家列表 local function updatePlayerList() playerListScroll:ClearAllChildren() local yOffset = 0 local entryHeight = 25 local padding = 5 for i, location in ipairs(teleportLocations) do local count = countPlayersNearPosition(location.position, 50) local entryFrame = Instance.new("Frame") entryFrame.Name = location.name entryFrame.Size = UDim2.new(1, -10, 0, entryHeight) entryFrame.Position = UDim2.new(0, 5, 0, yOffset) entryFrame.BackgroundColor3 = count > 0 and Color3.new(0.4, 0.2, 0.2) or Color3.new(0.3, 0.3, 0.3) entryFrame.BorderSizePixel = 0 entryFrame.ZIndex = 12 entryFrame.Parent = playerListScroll local nameLabel = Instance.new("TextLabel") nameLabel.Name = "Name" nameLabel.Size = UDim2.new(0.6, 0, 1, 0) nameLabel.Text = location.name nameLabel.TextColor3 = Color3.new(1, 1, 1) nameLabel.BackgroundTransparency = 1 nameLabel.Font = Enum.Font.SourceSans nameLabel.TextSize = 12 nameLabel.TextXAlignment = Enum.TextXAlignment.Left nameLabel.ZIndex = 13 nameLabel.Parent = entryFrame local countLabel = Instance.new("TextLabel") countLabel.Name = "Count" countLabel.Size = UDim2.new(0.3, 0, 1, 0) countLabel.Position = UDim2.new(0.6, 0, 0, 0) countLabel.Text = count .. " 人" countLabel.TextColor3 = count > 0 and Color3.new(1, 0.5, 0.5) or Color3.new(1, 1, 1) countLabel.BackgroundTransparency = 1 countLabel.Font = Enum.Font.SourceSansBold countLabel.TextSize = 12 countLabel.TextXAlignment = Enum.TextXAlignment.Right countLabel.ZIndex = 13 countLabel.Parent = entryFrame yOffset = yOffset + entryHeight + padding end playerListScroll.CanvasSize = UDim2.new(0, 0, 0, yOffset) end -- 更新死亡点列表 local function updateDeathList() deathListScroll:ClearAllChildren() local yOffset = 0 local entryHeight = 30 local padding = 5 for i, deathPoint in ipairs(deathPoints) do local entryFrame = Instance.new("Frame") entryFrame.Name = "DeathPoint" .. i entryFrame.Size = UDim2.new(1, -10, 0, entryHeight) entryFrame.Position = UDim2.new(0, 5, 0, yOffset) entryFrame.BackgroundColor3 = Color3.new(0.3, 0.3, 0.3) entryFrame.BorderSizePixel = 0 entryFrame.ZIndex = 12 entryFrame.Parent = deathListScroll -- 序号标签 local indexLabel = Instance.new("TextLabel") indexLabel.Name = "Index" indexLabel.Size = UDim2.new(0, 30, 1, 0) indexLabel.Text = tostring(i) indexLabel.TextColor3 = Color3.new(1, 1, 1) indexLabel.BackgroundTransparency = 1 indexLabel.Font = Enum.Font.SourceSansBold indexLabel.TextSize = 14 indexLabel.TextXAlignment = Enum.TextXAlignment.Center indexLabel.ZIndex = 13 indexLabel.Parent = entryFrame -- 传送按钮 local teleportButton = Instance.new("TextButton") teleportButton.Name = "TeleportButton" teleportButton.Size = UDim2.new(0.4, 0, 0.8, 0) teleportButton.Position = UDim2.new(0.3, 0, 0.1, 0) teleportButton.Text = "传送" teleportButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0) teleportButton.TextColor3 = Color3.new(0, 0, 0) teleportButton.Font = Enum.Font.SourceSansBold teleportButton.TextSize = 12 teleportButton.ZIndex = 13 teleportButton.Parent = entryFrame teleportButton.MouseButton1Click:Connect(function() if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = CFrame.new(deathPoint.position + Vector3.new(0, 5, 0)) end end) -- 删除按钮 local deleteButton = Instance.new("TextButton") deleteButton.Name = "DeleteButton" deleteButton.Size = UDim2.new(0.2, 0, 0.8, 0) deleteButton.Position = UDim2.new(0.75, 0, 0.1, 0) deleteButton.Text = "删除" deleteButton.BackgroundColor3 = Color3.fromRGB(255, 100, 100) deleteButton.TextColor3 = Color3.new(1, 1, 1) deleteButton.Font = Enum.Font.SourceSansBold deleteButton.TextSize = 12 deleteButton.ZIndex = 13 deleteButton.Parent = entryFrame deleteButton.MouseButton1Click:Connect(function() table.remove(deathPoints, i) updateDeathList() end) yOffset = yOffset + entryHeight + padding end deathListScroll.CanvasSize = UDim2.new(0, 0, 0, yOffset) end -- 添加死亡点 local function addDeathPoint(position) if #deathPoints >= maxDeathPoints then table.remove(deathPoints, 1) end table.insert(deathPoints, { position = position, timestamp = os.time() }) if deathListFrame.Visible then updateDeathList() end end -- 清除所有死亡记录 clearAllDeathsButton.MouseButton1Click:Connect(function() deathPoints = {} updateDeathList() end) -- 更新所有列表位置 local function updateAllListPositions() if not listFrame.Visible then return end local listFramePos = listFrame.AbsolutePosition local listFrameSize = listFrame.AbsoluteSize local viewportSize = workspace.CurrentCamera.ViewportSize -- 更新玩家列表位置 if playerListFrame.Visible then local targetX = listFramePos.X + listFrameSize.X + 5 local targetY = listFramePos.Y -- 如果右侧空间不足,显示在左侧 if targetX + playerListFrame.AbsoluteSize.X > viewportSize.X then targetX = listFramePos.X - playerListFrame.AbsoluteSize.X - 5 end playerListFrame.Position = UDim2.new(0, targetX, 0, targetY) end -- 更新死亡列表位置 if deathListFrame.Visible then local baseFrame = playerListFrame.Visible and playerListFrame or listFrame local basePos = baseFrame.AbsolutePosition local baseSize = baseFrame.AbsoluteSize local targetX = basePos.X + baseSize.X + 5 local targetY = basePos.Y -- 如果右侧空间不足,显示在左侧 if targetX + deathListFrame.AbsoluteSize.X > viewportSize.X then targetX = basePos.X - deathListFrame.AbsoluteSize.X - 5 end deathListFrame.Position = UDim2.new(0, targetX, 0, targetY) end end -- 点击人数按钮 playerCountButton.MouseButton1Click:Connect(function() playerListFrame.Visible = not playerListFrame.Visible playerListWasVisible = playerListFrame.Visible if playerListFrame.Visible then updatePlayerList() end updateAllListPositions() end) -- 点击死亡点按钮 deathPointButton.MouseButton1Click:Connect(function() deathListFrame.Visible = not deathListFrame.Visible deathListWasVisible = deathListFrame.Visible if deathListFrame.Visible then updateDeathList() end updateAllListPositions() end) -- 定期更新玩家数量 game:GetService("RunService").Heartbeat:Connect(function() if playerListFrame.Visible then updatePlayerList() end end) -- 死亡点记录功能 player.CharacterAdded:Connect(function(character) wait(1) local humanoid = character:WaitForChild("Humanoid") humanoid.Died:Connect(function() if character:FindFirstChild("HumanoidRootPart") then addDeathPoint(character.HumanoidRootPart.Position) end end) end) -- 重新加入服务器功能 rejoinButton.MouseButton1Click:Connect(function() local TeleportService = game:GetService("TeleportService") local success, errorMsg = pcall(function() TeleportService:TeleportToPlaceInstance(game.PlaceId, game.JobId, player) end) if not success then warn("重新加入失败: " .. tostring(errorMsg)) rejoinButton.Text = "重新加入失败" wait(2) rejoinButton.Text = "重新加入服务器" end end) -- 点击悬浮球显示/隐藏所有列表 local isListVisible = false ball.MouseButton1Click:Connect(function() isListVisible = not isListVisible listFrame.Visible = isListVisible if isListVisible then -- 恢复之前的状态 updateListPosition() playerListFrame.Visible = playerListWasVisible deathListFrame.Visible = deathListWasVisible -- 更新内容 if playerListFrame.Visible then updatePlayerList() end if deathListFrame.Visible then updateDeathList() end updateAllListPositions() else -- 关闭时记住当前状态 playerListWasVisible = playerListFrame.Visible deathListWasVisible = deathListFrame.Visible -- 关闭所有列表 playerListFrame.Visible = false deathListFrame.Visible = false end end) -- 更新主列表位置函数 local function updateListPosition() local ballPos = ball.AbsolutePosition local ballSize = ball.AbsoluteSize local viewportSize = workspace.CurrentCamera.ViewportSize local targetX = ballPos.X + ballSize.X + 5 local targetY = ballPos.Y -- 如果右侧空间不足,显示在左侧 if targetX + listFrame.AbsoluteSize.X > viewportSize.X then targetX = ballPos.X - listFrame.AbsoluteSize.X - 5 end -- 如果底部空间不足,调整Y位置 if targetY + listFrame.AbsoluteSize.Y > viewportSize.Y then targetY = viewportSize.Y - listFrame.AbsoluteSize.Y - 5 end listFrame.Position = UDim2.new(0, targetX, 0, targetY) end -- 当球移动时更新所有列表位置 ball:GetPropertyChangedSignal("AbsolutePosition"):Connect(function() if listFrame.Visible then updateListPosition() updateAllListPositions() end end) -- 当列表移动时更新其他列表位置 listFrame:GetPropertyChangedSignal("AbsolutePosition"):Connect(function() if listFrame.Visible then updateAllListPositions() end end) -- 初始隐藏所有列表 listFrame.Visible = false playerListFrame.Visible = false deathListFrame.Visible = false -- 确保悬浮球始终在最上层 coroutine.wrap(function() while true do wait(1) ball.ZIndex = 100 ballText.ZIndex = 101 end end)() end -- 为所有玩家创建GUI Players.PlayerAdded:Connect(createTeleportGUI) -- 为已存在的玩家创建GUI for _, player in ipairs(Players:GetPlayers()) do createTeleportGUI(player) end