Advertisement
m9aari

grab all tools

Nov 16th, 2024 (edited)
9,806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. -- Variables
  2. local player = game.Players.LocalPlayer
  3. local originalPosition = player.Character.HumanoidRootPart.CFrame
  4. local debrisFolder = game.Workspace:WaitForChild("Debris")
  5. local weaponDisplays = debrisFolder:GetChildren()
  6. local proximityPromptName = "ProximityPrompt"
  7.  
  8. -- Function to teleport to a random WEAPON_DISPLAY
  9. local function teleportToRandomWeaponDisplay()
  10. -- Get all MeshParts named "WEAPON_DISPLAY" in the folder
  11. local weaponDisplayParts = {}
  12. for _, part in ipairs(weaponDisplays) do
  13. if part:IsA("MeshPart") and part.Name == "WEAPON_DISPLAY" then
  14. table.insert(weaponDisplayParts, part)
  15. end
  16. end
  17.  
  18. -- Select a random weapon display from the list
  19. local randomWeaponDisplay = weaponDisplayParts[math.random(1, #weaponDisplayParts)]
  20.  
  21. -- Teleport to the selected WEAPON_DISPLAY
  22. player.Character.HumanoidRootPart.CFrame = randomWeaponDisplay.CFrame
  23. end
  24.  
  25. -- Function to interact with the ProximityPrompt and teleport back
  26. local function interactWithProximityPrompt()
  27. -- Find the ProximityPrompt inside the current WEAPON_DISPLAY
  28. local currentWeaponDisplay = player.Character:FindFirstChild("HumanoidRootPart")
  29. local proximityPrompt = currentWeaponDisplay and currentWeaponDisplay.Parent:FindFirstChild(proximityPromptName)
  30.  
  31. if proximityPrompt then
  32. -- Trigger the ProximityPrompt interaction
  33. proximityPrompt.ActionTriggered:Connect(function()
  34. -- Teleport the player back to the original position
  35. player.Character.HumanoidRootPart.CFrame = originalPosition
  36. end)
  37. end
  38. end
  39.  
  40. -- Call the functions
  41. teleportToRandomWeaponDisplay()
  42. wait(1) -- Wait a moment for teleportation
  43. interactWithProximityPrompt()
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement