ADVERTISEMENTREMOVE ADS

ESP---It's just used to tell the distance to other players

Universal script
8 months ago
Script preview thumbnail
Script Preview

Description

It's just used to tell the distance to other players [[[[Alt+Shift]]]]]

ADVERTISEMENTREMOVE ADS
156 Lines • 5.58 KiB
Raw
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local isSystemEnabled = false -- สถานะการเปิด/ปิดระบบ
local targetPlayers = {} -- ตารางเก็บข้อมูลผู้เล่นคนอื่น
-- สร้าง GUI สำหรับเมนู
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = player.PlayerGui
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.2, 0, 0.1, 0)
frame.Position = UDim2.new(0.05, 0, 0.05, 0)
frame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
frame.Parent = screenGui
local toggleButton = Instance.new("TextButton")
toggleButton.Size = UDim2.new(0.8, 0, 0.6, 0)
toggleButton.Position = UDim2.new(0.1, 0, 0.2, 0)
toggleButton.Text = "Enable System"
toggleButton.BackgroundColor3 = Color3.new(0.4, 0.4, 0.4)
toggleButton.Parent = frame
-- ฟังก์ชันเปิด/ปิดระบบทั้งหมด
local function toggleSystem()
isSystemEnabled = not isSystemEnabled
toggleButton.Text = isSystemEnabled and "Disable System" or "Enable System"
frame.Visible = isSystemEnabled -- ซ่อนหรือแสดง GUI
if not isSystemEnabled then
-- ปิดระบบ: ลบ Highlight และ TextLabel
for _, targetData in pairs(targetPlayers) do
if targetData.highlight then
targetData.highlight:Destroy()
end
if targetData.distanceLabel then
targetData.distanceLabel:Destroy()
end
end
targetPlayers = {}
end
end
toggleButton.MouseButton1Click:Connect(toggleSystem)
-- ฟังก์ชันตรวจจับการกด Alt + Shift
local altPressed = false
local shiftPressed = false
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end -- ไม่ทำงานหากการกดปุ่มถูกประมวลผลโดยเกมแล้ว
if input.KeyCode == Enum.KeyCode.LeftAlt or input.KeyCode == Enum.KeyCode.RightAlt then
altPressed = true
elseif input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
shiftPressed = true
end
-- ตรวจสอบว่ากด Alt + Shift พร้อมกันหรือไม่
if altPressed and shiftPressed then
toggleSystem()
altPressed = false
shiftPressed = false
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftAlt or input.KeyCode == Enum.KeyCode.RightAlt then
altPressed = false
elseif input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
shiftPressed = false
end
end)
-- ฟังก์ชันสร้าง Highlight และ TextLabel สำหรับผู้เล่น
local function createHighlight(targetCharacter)
local highlight = Instance.new("Highlight")
highlight.Parent = targetCharacter
highlight.FillTransparency = 0.5
highlight.OutlineTransparency = 0
-- สร้าง TextLabel เพื่อแสดงระยะทาง
local distanceLabel = Instance.new("TextLabel")
distanceLabel.Size = UDim2.new(0, 100, 0, 30)
distanceLabel.BackgroundColor3 = Color3.new(0, 0, 0)
distanceLabel.TextColor3 = Color3.new(1, 1, 1)
distanceLabel.Text = "0 studs"
distanceLabel.Parent = screenGui
return highlight, distanceLabel
end
-- ฟังก์ชันอัพเดทสีและระยะทาง
local function updateTarget(targetData)
local distance = (targetData.rootPart.Position - rootPart.Position).Magnitude
targetData.distanceLabel.Text = string.format("%.1f studs", distance) -- แสดงระยะทางเป็นตัวเลข
-- เปลี่ยนสี Highlight ตามระยะทาง
if distance < 20 then
targetData.highlight.FillColor = Color3.new(0, 1, 0) -- สีเขียว (ใกล้)
elseif distance < 50 then
targetData.highlight.FillColor = Color3.new(1, 1, 0) -- สีเหลือง (ปานกลาง)
else
targetData.highlight.FillColor = Color3.new(1, 0, 0) -- สีแดง (ไกล)
end
-- อัพเดทตำแหน่ง TextLabel ให้อยู่เหนือผู้เล่น
local screenPosition, onScreen = workspace.CurrentCamera:WorldToViewportPoint(targetData.rootPart.Position)
if onScreen then
targetData.distanceLabel.Position = UDim2.new(0, screenPosition.X, 0, screenPosition.Y - 50)
targetData.distanceLabel.Visible = true
else
targetData.distanceLabel.Visible = false
end
end
-- ตรวจจับผู้เล่นคนอื่น
local function trackPlayers()
for _, otherPlayer in pairs(Players:GetPlayers()) do
if otherPlayer ~= player and otherPlayer.Character then
local targetCharacter = otherPlayer.Character
local targetRoot = targetCharacter:FindFirstChild("HumanoidRootPart")
if targetRoot and not targetPlayers[otherPlayer.UserId] then
local highlight, distanceLabel = createHighlight(targetCharacter)
targetPlayers[otherPlayer.UserId] = {
character = targetCharacter,
rootPart = targetRoot,
highlight = highlight,
distanceLabel = distanceLabel
}
end
end
end
end
-- อัพเดททุกเฟรม
RunService.Heartbeat:Connect(function()
if not isSystemEnabled then return end
-- อัพเดทการติดตามผู้เล่น
trackPlayers()
-- อัพเดทสีและระยะทาง
for _, targetData in pairs(targetPlayers) do
if targetData.character and targetData.rootPart and targetData.highlight and targetData.distanceLabel then
updateTarget(targetData)
end
end
end)
ADVERTISEMENTREMOVE ADS

Comments

0 comments
to add a comment
Loading comments
ADVERTISEMENTREMOVE ADS