Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local UserInputService = game:GetService("UserInputService")
- local Stats = game:GetService("Stats")
- local CoreGui = game:GetService("CoreGui")
- local LocalPlayer = Players.LocalPlayer
- local mouse = LocalPlayer:GetMouse()
- local sitting = false
- local targetPlayer = nil
- local basePrediction = 0.1
- local calculatedPhysicsPing = 0
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Name = "HeadsitGUI"
- ScreenGui.ResetOnSpawn = false
- -- Useless ai bs
- local success, uiParent = pcall(function() return gethui() or CoreGui end)
- if not success then uiParent = LocalPlayer:WaitForChild("PlayerGui") end
- ScreenGui.Parent = uiParent
- local MainFrame = Instance.new("Frame")
- MainFrame.Size = UDim2.new(0, 200, 0, 230)
- MainFrame.Position = UDim2.new(0.5, -100, 0.5, -115)
- MainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
- MainFrame.BorderSizePixel = 0
- MainFrame.Parent = ScreenGui
- local UICorner = Instance.new("UICorner")
- UICorner.CornerRadius = UDim.new(0, 8)
- UICorner.Parent = MainFrame
- local Title = Instance.new("TextLabel")
- Title.Size = UDim2.new(1, 0, 0, 30)
- Title.BackgroundTransparency = 1
- Title.Text = "Headsit + Ping"
- Title.TextColor3 = Color3.fromRGB(255, 255, 255)
- Title.Font = Enum.Font.GothamBold
- Title.TextSize = 14
- Title.Parent = MainFrame
- local TargetBox = Instance.new("TextBox")
- TargetBox.Size = UDim2.new(0.9, 0, 0, 30)
- TargetBox.Position = UDim2.new(0.05, 0, 0, 40)
- TargetBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- TargetBox.TextColor3 = Color3.fromRGB(255, 255, 255)
- TargetBox.PlaceholderText = "Target Name..."
- TargetBox.Font = Enum.Font.Gotham
- TargetBox.TextSize = 14
- TargetBox.Parent = MainFrame
- local PredictionBox = Instance.new("TextBox")
- PredictionBox.Size = UDim2.new(0.9, 0, 0, 30)
- PredictionBox.Position = UDim2.new(0.05, 0, 0, 80)
- PredictionBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
- PredictionBox.TextColor3 = Color3.fromRGB(255, 255, 255)
- PredictionBox.PlaceholderText = "Base Predict (e.g. 0.1)"
- PredictionBox.Text = "0.1"
- PredictionBox.Font = Enum.Font.Gotham
- PredictionBox.TextSize = 14
- PredictionBox.Parent = MainFrame
- local SitButton = Instance.new("TextButton")
- SitButton.Size = UDim2.new(0.9, 0, 0, 35)
- SitButton.Position = UDim2.new(0.05, 0, 0, 125)
- SitButton.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
- SitButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- SitButton.Text = "Start Headsit"
- SitButton.Font = Enum.Font.GothamBold
- SitButton.TextSize = 14
- SitButton.Parent = MainFrame
- local PingButton = Instance.new("TextButton")
- PingButton.Size = UDim2.new(0.9, 0, 0, 35)
- PingButton.Position = UDim2.new(0.05, 0, 0, 175)
- PingButton.BackgroundColor3 = Color3.fromRGB(255, 100, 100)
- PingButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- PingButton.Text = "Get Ping Tool"
- PingButton.Font = Enum.Font.GothamBold
- PingButton.TextSize = 14
- PingButton.Parent = MainFrame
- local dragging, dragInput, dragStart, startPos
- MainFrame.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 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)
- MainFrame.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement then dragInput = input end
- end)
- UserInputService.InputChanged:Connect(function(input)
- if input == dragInput and dragging then
- 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
- end)
- local function getPlayer(nameStr)
- if not nameStr or nameStr == "" then return nil end
- local lowerName = string.lower(nameStr)
- for _, p in ipairs(Players:GetPlayers()) do
- if p ~= LocalPlayer then
- if string.sub(string.lower(p.Name), 1, #lowerName) == lowerName or string.sub(string.lower(p.DisplayName), 1, #lowerName) == lowerName then
- return p
- end
- end
- end
- return nil
- end
- local function getNetworkPing()
- local activePing = 0
- local success, result = pcall(function()
- local label = CoreGui.RobloxGui.PerformanceStats:GetChildren()[6].StatsMiniTextPanelClass.ValueLabel
- return label.Text
- end)
- if success and type(result) == "string" then
- local numStr = string.match(result, "[%d%.]+")
- if numStr then return tonumber(numStr) end
- end
- local statSuccess, statResult = pcall(function()
- return Stats.Network.ServerStatsItem["Data Ping"]:GetValue()
- end)
- if statSuccess and type(statResult) == "number" then
- return statResult
- end
- return activePing
- end
- PredictionBox.FocusLost:Connect(function()
- local val = tonumber(PredictionBox.Text)
- if val then
- basePrediction = val
- else
- PredictionBox.Text = tostring(basePrediction)
- end
- end)
- SitButton.MouseButton1Click:Connect(function()
- sitting = not sitting
- if sitting then
- local p = getPlayer(TargetBox.Text)
- if p then
- targetPlayer = p
- SitButton.Text = "Stop Headsit"
- SitButton.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
- local hum = LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("Humanoid")
- if hum then hum.Sit = true end
- else
- sitting = false
- SitButton.Text = "Player not found!"
- task.wait(1)
- SitButton.Text = "Start Headsit"
- SitButton.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
- end
- else
- targetPlayer = nil
- SitButton.Text = "Start Headsit"
- SitButton.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
- Title.Text = "Headsit + Ping"
- local hum = LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("Humanoid")
- if hum then hum.Sit = false end
- end
- end)
- RunService.Heartbeat:Connect(function()
- if sitting and targetPlayer and targetPlayer.Character then
- local lChar = LocalPlayer.Character
- local tChar = targetPlayer.Character
- local myHRP = lChar and lChar:FindFirstChild("HumanoidRootPart")
- local tHRP = tChar and tChar:FindFirstChild("HumanoidRootPart")
- local myHum = lChar and lChar:FindFirstChild("Humanoid")
- if myHRP and tHRP then
- if myHum and not myHum.Sit then myHum.Sit = true end
- for _, part in ipairs(lChar:GetDescendants()) do
- if part:IsA("BasePart") then part.CanCollide = false end
- end
- local dynamicPingDelay = 0
- if calculatedPhysicsPing > 0 then
- local currentNetPing = getNetworkPing()
- local differenceMs = math.max(0, calculatedPhysicsPing - currentNetPing)
- dynamicPingDelay = differenceMs / 1000
- Title.Text = string.format("Net: %d | Delay: %d", currentNetPing, differenceMs)
- end
- local totalPrediction = basePrediction + dynamicPingDelay
- local verticalOffset = CFrame.new(0, 2.35, 0)
- local predictedVelocityOffset = (tHRP.AssemblyLinearVelocity * totalPrediction)
- myHRP.CFrame = (tHRP.CFrame + predictedVelocityOffset) * verticalOffset
- myHRP.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
- myHRP.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
- end
- end
- end)
- PingButton.MouseButton1Click:Connect(function()
- if LocalPlayer.Backpack:FindFirstChild("PingCheck") then
- PingButton.Text = "Already have Tool!"
- task.wait(1)
- PingButton.Text = "Get Ping Tool"
- return
- end
- local tool = Instance.new("Tool")
- tool.Name = "PingCheck"
- tool.RequiresHandle = false
- tool.Parent = LocalPlayer.Backpack
- local function getHRP(p)
- local c = p and p.Character
- return c and c:FindFirstChild("HumanoidRootPart")
- end
- local function noCollide(c)
- for _, d in ipairs(c:GetDescendants()) do
- if d:IsA("BasePart") then d.CanCollide = false end
- end
- end
- local function slide(part, goal, dur)
- local tw = TweenService:Create(part, TweenInfo.new(dur, Enum.EasingStyle.Linear), { CFrame = goal })
- tw:Play()
- tw.Completed:Wait()
- end
- local function run(target)
- local th = getHRP(target)
- local mh = getHRP(LocalPlayer)
- if not th or not mh then return end
- noCollide(LocalPlayer.Character)
- task.wait(0.2)
- local last = th.Position
- local still = 0
- while still < 30 do
- RunService.Heartbeat:Wait()
- th = getHRP(target) or th
- local p = th.Position
- if (p - last).Magnitude > 0.15 then still = 0 else still += 1 end
- last = p
- end
- mh = getHRP(LocalPlayer) or mh
- th = getHRP(target) or th
- slide(mh, th.CFrame * CFrame.new(0, 0, 10), 1.2)
- task.wait(0.5)
- local t0 = nil
- local p0 = nil
- local moved = false
- local ms = 0
- local done = false
- local endT = nil
- task.spawn(function()
- local m = getHRP(LocalPlayer) or mh
- local t = getHRP(target) or th
- slide(m, t.CFrame * CFrame.new(0, 0, -10), 1.2)
- done = true
- endT = os.clock()
- end)
- while not moved do
- RunService.Heartbeat:Wait()
- mh = getHRP(LocalPlayer) or mh
- th = getHRP(target) or th
- if not t0 then
- if (mh.Position - th.Position).Magnitude <= 3 then
- t0 = os.clock()
- p0 = th.Position
- elseif done and endT and (os.clock() - endT) > 5 then
- break
- end
- else
- ms = (os.clock() - t0) * 1000
- if (th.Position - p0).Magnitude > 0.05 then
- moved = true
- elseif ms > 5000 then
- break
- end
- end
- end
- if moved then
- print(string.format("Calculated Physics Ping: %.6f ms", ms))
- -- Updates our total physics ping delay variable
- calculatedPhysicsPing = ms
- Title.Text = string.format("Phys Ping: %dms", ms)
- end
- end
- tool.Activated:Connect(function()
- local hit = mouse.Target
- if not hit then return end
- local model = hit:FindFirstAncestorOfClass("Model")
- if not model then return end
- local plr = Players:GetPlayerFromCharacter(model)
- if plr and plr ~= LocalPlayer then
- run(plr)
- end
- end)
- PingButton.Text = "Tool Given!"
- task.wait(1)
- PingButton.Text = "Get Ping Tool"
- end)
Advertisement
Add Comment
Please, Sign In to add comment