Advertisement
1_F0

Untitled

Aug 25th, 2023
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. --[[
  2. WARNING: Heads up! This script has not been verified by ScriptBlox. Use at your own risk!
  3. ]]
  4. local player = game.Players.LocalPlayer
  5. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  6. local remoteEvent = ReplicatedStorage:WaitForChild("b")
  7. local Workspace = game:GetService("Workspace")
  8.  
  9. local detectionRange = 750
  10. local heightUnderPlayer = 5
  11. local safeDistanceFromRock = 50
  12.  
  13. local function hasErrorTool(player)
  14. if player.Backpack:FindFirstChild("Error") or (player.Character and player.Character:FindFirstChild("Error")) then
  15. return true
  16. end
  17. return false
  18. end
  19.  
  20. local function isTransparent(character)
  21. for _, part in pairs(character:GetChildren()) do
  22. if part:IsA("MeshPart") or part:IsA("Part") then
  23. if part.Transparency == 0.5 then
  24. return true
  25. end
  26. end
  27. end
  28. return false
  29. end
  30.  
  31. local function isWithinLobbyArea(character)
  32. return game:GetService("Workspace").Lobby:IsAncestorOf(character)
  33. end
  34.  
  35. local function distanceFromRock(position)
  36. local rock = Workspace:FindFirstChild("rock")
  37. if rock then
  38. return (position - rock.Position).Magnitude
  39. end
  40. return math.huge
  41. end
  42.  
  43. local function getClosestPlayer(character)
  44. local shortestDistance = math.huge
  45. local closestPlayer = nil
  46.  
  47. for _, otherPlayer in ipairs(game.Players:GetPlayers()) do
  48. if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("Head")
  49. and not isTransparent(otherPlayer.Character) and not isWithinLobbyArea(otherPlayer.Character)
  50. and distanceFromRock(otherPlayer.Character.Head.Position) > safeDistanceFromRock
  51. and not hasErrorTool(otherPlayer) then
  52. local distance = (character.Head.Position - otherPlayer.Character.Head.Position).Magnitude
  53. if distance < shortestDistance then
  54. shortestDistance = distance
  55. closestPlayer = otherPlayer
  56. end
  57. end
  58. end
  59.  
  60. return closestPlayer
  61. end
  62.  
  63. local function createPlatform(position)
  64. local platform = Instance.new("Part")
  65. platform.Position = position
  66. platform.Size = Vector3.new(10, 1, 10)
  67. platform.Anchored = true
  68. platform.CanCollide = true
  69. platform.BrickColor = BrickColor.new("Really black") -- Set to black color
  70. platform.Transparency = 1 -- Set to invisible
  71. platform.Parent = Workspace
  72. return platform
  73. end
  74.  
  75. local function continuousTeleportAndActivate(character)
  76. local platform = nil
  77.  
  78. character.Humanoid.Died:Connect(function()
  79. character:SetPrimaryPartCFrame(Workspace.Lobby.Teleport1.CFrame)
  80. wait(1)
  81. end)
  82.  
  83. while true do
  84. local closestPlayer = getClosestPlayer(character)
  85. if closestPlayer and closestPlayer.Character and closestPlayer.Character:FindFirstChild("HumanoidRootPart") then
  86. local humanoid = closestPlayer.Character:FindFirstChild("Humanoid")
  87. if humanoid and humanoid.Health <= 0 then
  88. wait(0.1)
  89. closestPlayer = getClosestPlayer(character)
  90. end
  91. character:SetPrimaryPartCFrame(closestPlayer.Character.HumanoidRootPart.CFrame * CFrame.new(0, -heightUnderPlayer, 0))
  92.  
  93. if not platform then
  94. platform = createPlatform(character.HumanoidRootPart.Position + Vector3.new(0, 3, 0))
  95. else
  96. platform.Position = character.HumanoidRootPart.Position + Vector3.new(0, 3, 0)
  97. end
  98.  
  99. local args = {[1] = closestPlayer.Character.Head}
  100. remoteEvent:FireServer(unpack(args))
  101. end
  102. wait(0)
  103. end
  104. end
  105.  
  106. player.CharacterAdded:Connect(continuousTeleportAndActivate)
  107. local currentCharacter = player.Character or player.CharacterAdded:Wait()
  108. continuousTeleportAndActivate(currentCharacter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement