Advertisement
timmie140

Tower Chest Logic (World Zero)

Dec 28th, 2024 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. --Note when the boss is killed, it won't get all if it did not have a double chest pass on (might fix when adding logic on fighting bosses)
  2.  
  3. -- Global variables to control teleportation
  4. _G.PurpleChest = _G.PurpleChest or false -- true: Teleport to RaidChestSilver, false: Do nothing
  5. _G.GoldChest = _G.GoldChest or false -- true: Teleport to RaidChestGold, false: Do nothing
  6. _G.HaveDoubleChestPass = _G.HaveDoubleChestPass or false -- true: Can teleport to both, false: Cannot teleport to both
  7.  
  8. -- Services
  9. local players = game:GetService("Players")
  10. local workspace = game:GetService("Workspace")
  11.  
  12. -- Variables
  13. local raidChestSilverName = "RaidChestSilver"
  14. local raidChestGoldName = "RaidChestGold"
  15. local player = players.LocalPlayer
  16. local character = player.Character or player.CharacterAdded:Wait()
  17.  
  18. -- Function to simulate clicking and teleporting to the chest
  19. local function simulateClick(chest)
  20. if character and chest then
  21. -- Ensure the player's character has a HumanoidRootPart
  22. local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
  23. if humanoidRootPart then
  24. -- Debug print to check if the player is detected and the chest is found
  25. print("Simulating click on chest...")
  26.  
  27. -- Get the ChessBase part as the PrimaryPart
  28. local primaryPart = chest:FindFirstChild("ChestBase")
  29. if primaryPart then
  30. -- Directly set the player's CFrame to the chest's PrimaryPart (ChestBase)
  31. character:SetPrimaryPartCFrame(primaryPart.CFrame + Vector3.new(0, 5, 0)) -- Slight offset above chest
  32.  
  33. -- Debug print to confirm the action
  34. print("Simulated click successful!")
  35. else
  36. print("ChestBase part not found!")
  37. end
  38. else
  39. print("HumanoidRootPart not found!")
  40. end
  41. end
  42. end
  43.  
  44. -- Function to check for the chest's existence and simulate click
  45. local function checkAndClick()
  46. -- Check if both chests are set to true and if double chest pass is not enabled
  47. if _G.PurpleChest and _G.GoldChest then
  48. if not _G.HaveDoubleChestPass then
  49. print("Error: Can't have both RaidChestSilver and RaidChestGold enabled at the same time.")
  50. return
  51. end
  52. end
  53.  
  54. -- Only proceed if PurpleChest is true
  55. if _G.PurpleChest then
  56. -- Find the RaidChestSilver in the workspace
  57. local chestSilver = workspace:FindFirstChild(raidChestSilverName)
  58. if chestSilver and chestSilver:IsA("Model") then
  59. -- Ensure the chest has the ChestBase PrimaryPart
  60. if chestSilver:FindFirstChild("ChestBase") then
  61. -- Simulate a click if chest exists
  62. print("RaidChestSilver found!")
  63. simulateClick(chestSilver)
  64. else
  65. print("RaidChestSilver found, but ChestBase part is missing.")
  66. end
  67. else
  68. print("RaidChestSilver not found.")
  69. end
  70. end
  71.  
  72. -- Only proceed if GoldChest is true
  73. if _G.GoldChest then
  74. -- Find the RaidChestGold in the workspace
  75. local chestGold = workspace:FindFirstChild(raidChestGoldName)
  76. if chestGold and chestGold:IsA("Model") then
  77. -- Ensure the chest has the ChestBase PrimaryPart
  78. if chestGold:FindFirstChild("ChestBase") then
  79. -- Simulate a click if chest exists
  80. print("RaidChestGold found!")
  81. simulateClick(chestGold)
  82. else
  83. print("RaidChestGold found, but ChestBase part is missing.")
  84. end
  85. else
  86. print("RaidChestGold not found.")
  87. end
  88. end
  89. end
  90.  
  91. -- Initial check when the script starts
  92. checkAndClick()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement