eldenzkie14

8 BALL POOL

Nov 18th, 2025 (edited)
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.94 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3.  
  4. -- Wait for workspace to load
  5. wait(1)
  6.  
  7. -- Safe object finding with error handling
  8. local function findObjectWithDebug(path)
  9.     local current = workspace
  10.     for _, name in ipairs(path) do
  11.         current = current:FindFirstChild(name)
  12.         if not current then
  13.             warn("Could not find: " .. name .. " in path: " .. table.concat(path, "."))
  14.             return nil
  15.         end
  16.     end
  17.     return current
  18. end
  19.  
  20. -- Try to find the trajectory guide
  21. local HitTrajectory
  22. local Table1 = workspace:FindFirstChild("Tables")
  23.  
  24. if Table1 then
  25.     Table1 = Table1:FindFirstChild("Table1")
  26.     if Table1 then
  27.         local Guides = Table1:FindFirstChild("Guides")
  28.         if Guides then
  29.             HitTrajectory = Guides:FindFirstChild("HitTrajectory")
  30.         end
  31.     end
  32. end
  33.  
  34. -- If not found, create a test trajectory guide
  35. if not HitTrajectory then
  36.     warn("HitTrajectory not found in expected location. Creating test guide...")
  37.    
  38.     -- Create test objects
  39.     local testFolder = Instance.new("Folder")
  40.     testFolder.Name = "TestTrajectory"
  41.     testFolder.Parent = workspace
  42.    
  43.     HitTrajectory = Instance.new("Part")
  44.     HitTrajectory.Name = "HitTrajectory"
  45.     HitTrajectory.Size = Vector3.new(1, 1, 1)
  46.     HitTrajectory.Position = Vector3.new(0, 5, 0)
  47.     HitTrajectory.Anchored = true
  48.     HitTrajectory.CanCollide = false
  49.     HitTrajectory.Transparency = 0.5
  50.     HitTrajectory.BrickColor = BrickColor.new("Bright red")
  51.     HitTrajectory.Parent = testFolder
  52.    
  53.     -- Make it move for testing
  54.     local connection
  55.     local startTime = tick()
  56.     connection = RunService.Heartbeat:Connect(function()
  57.         local time = tick() - startTime
  58.         HitTrajectory.Position = Vector3.new(math.sin(time) * 10, 5, math.cos(time) * 10)
  59.         HitTrajectory.CFrame = CFrame.lookAt(HitTrajectory.Position, Vector3.new(0, 5, 0))
  60.     end)
  61. end
  62.  
  63. print("HitTrajectory found:", HitTrajectory ~= nil)
  64.  
  65. -- Enhanced configuration
  66. local config = {
  67.     maxSegments = 8,
  68.     segmentLength = 6,
  69.     maxBounces = 3,
  70.     ballRadius = 1.2,
  71.     powerMultiplier = 1.5,
  72.     fadeIntensity = true,
  73.     showBouncePoints = true
  74. }
  75.  
  76. local trajectoryParts = {}
  77. local bounceMarkers = {}
  78. local currentPower = 1.0
  79.  
  80. -- Material colors for visual appeal
  81. local colors = {
  82.     primary = BrickColor.new("Bright green"),
  83.     secondary = BrickColor.new("Bright blue"),
  84.     bounce = BrickColor.new("Bright yellow"),
  85.     fade = BrickColor.new("Dark green")
  86. }
  87.  
  88. -- Create a better looking trajectory segment
  89. local function createTrajectorySegment(position, direction, length, alpha, isBounce)
  90.     local part = Instance.new("Part")
  91.     part.Size = Vector3.new(0.3, 0.3, length)
  92.     part.CFrame = CFrame.lookAt(position, position + direction) * CFrame.new(0, 0, -length / 2)
  93.     part.Anchored = true
  94.     part.CanCollide = false
  95.     part.CastShadow = false
  96.    
  97.     -- Visual customization
  98.     local material = isBounce and Enum.Material.Neon or Enum.Material.SmoothPlastic
  99.     part.Material = material
  100.    
  101.     local color = isBounce and colors.bounce or colors.primary
  102.     if config.fadeIntensity then
  103.         part.BrickColor = color
  104.         part.Transparency = 0.2 + (alpha * 0.6)
  105.     else
  106.         part.BrickColor = color
  107.         part.Transparency = 0.2
  108.     end
  109.    
  110.     part.Parent = workspace
  111.    
  112.     return part
  113. end
  114.  
  115. -- Create bounce marker
  116. local function createBounceMarker(position)
  117.     if not config.showBouncePoints then return end
  118.    
  119.     local marker = Instance.new("Part")
  120.     marker.Size = Vector3.new(1, 1, 1)
  121.     marker.Shape = Enum.PartType.Ball
  122.     marker.CFrame = CFrame.new(position)
  123.     marker.BrickColor = colors.bounce
  124.     marker.Material = Enum.Material.Neon
  125.     marker.Anchored = true
  126.     marker.CanCollide = false
  127.     marker.Transparency = 0.2
  128.     marker.Parent = workspace
  129.    
  130.     return marker
  131. end
  132.  
  133. -- Clear all trajectory visuals
  134. local function clearTrajectory()
  135.     for _, part in pairs(trajectoryParts) do
  136.         if part and part.Parent then
  137.             part:Destroy()
  138.         end
  139.     end
  140.     trajectoryParts = {}
  141.    
  142.     for _, marker in pairs(bounceMarkers) do
  143.         if marker and marker.Parent then
  144.             marker:Destroy()
  145.         end
  146.     end
  147.     bounceMarkers = {}
  148. end
  149.  
  150. -- Simple trajectory calculation without complex physics
  151. local function calculateSimpleTrajectory(startPos, direction, power)
  152.     local currentPos = startPos
  153.     local currentDir = direction
  154.    
  155.     for i = 1, config.maxSegments do
  156.         local nextPos = currentPos + currentDir * config.segmentLength * power
  157.        
  158.         -- Simple wall collision (table boundaries)
  159.         local hit, hitPos = workspace:FindPartOnRay(Ray.new(currentPos, currentDir * config.segmentLength * power))
  160.        
  161.         if hit and hit.Name ~= "HitTrajectory" then
  162.             -- Bounce calculation
  163.             local normal = (hitPos - hit.Position).Unit
  164.             currentDir = currentDir - 2 * currentDir:Dot(normal) * normal
  165.             nextPos = hitPos + currentDir * 2
  166.            
  167.             -- Create bounce marker
  168.             local marker = createBounceMarker(hitPos)
  169.             table.insert(bounceMarkers, marker)
  170.         end
  171.        
  172.         -- Create trajectory segment
  173.         local segmentLength = (nextPos - currentPos).Magnitude
  174.         local alpha = (i - 1) / config.maxSegments
  175.         local segment = createTrajectorySegment(currentPos, currentDir, segmentLength, alpha, hit ~= nil)
  176.         table.insert(trajectoryParts, segment)
  177.        
  178.         currentPos = nextPos
  179.        
  180.         -- Stop if we've hit too many things
  181.         if hit then
  182.             break
  183.         end
  184.     end
  185. end
  186.  
  187. -- Main trajectory update function
  188. local function updateTrajectory()
  189.     if not HitTrajectory or not HitTrajectory.Parent then
  190.         warn("HitTrajectory is missing!")
  191.         return
  192.     end
  193.    
  194.     clearTrajectory()
  195.    
  196.     local startPos = HitTrajectory.Position
  197.     local direction = HitTrajectory.CFrame.LookVector.Unit
  198.    
  199.     -- Add some upward angle for better visualization
  200.     direction = (direction + Vector3.new(0, 0.1, 0)).Unit
  201.    
  202.     print("Updating trajectory from:", startPos, "Direction:", direction)
  203.    
  204.     -- Calculate simple trajectory
  205.     calculateSimpleTrajectory(startPos, direction, currentPower)
  206. end
  207.  
  208. -- Power control functions
  209. local function setPower(power)
  210.     currentPower = math.clamp(power, 0.1, 2.0)
  211.     print("Power set to:", currentPower)
  212.     updateTrajectory()
  213. end
  214.  
  215. -- Connect events
  216. if HitTrajectory then
  217.     HitTrajectory:GetPropertyChangedSignal("CFrame"):Connect(updateTrajectory)
  218.     print("Connected to HitTrajectory CFrame changes")
  219. else
  220.     warn("Cannot connect to HitTrajectory - object not found")
  221. end
  222.  
  223. -- Initial update
  224. wait(0.5)
  225. updateTrajectory()
  226. print("Trajectory system initialized!")
  227.  
  228. -- Add some test controls
  229. local function setupTestControls()
  230.     local player = Players.LocalPlayer
  231.     if player then
  232.         local playerGui = player:FindFirstChildOfClass("PlayerGui")
  233.         if playerGui then
  234.             -- Create test screen GUI
  235.             local screenGui = Instance.new("ScreenGui")
  236.             screenGui.Name = "TrajectoryTestGui"
  237.             screenGui.Parent = playerGui
  238.            
  239.             local frame = Instance.new("Frame")
  240.             frame.Size = UDim2.new(0, 200, 0, 120)
  241.             frame.Position = UDim2.new(0, 10, 0, 10)
  242.             frame.BackgroundColor3 = Color3.new(0, 0, 0)
  243.             frame.BackgroundTransparency = 0.3
  244.             frame.Parent = screenGui
  245.            
  246.             local powerLabel = Instance.new("TextLabel")
  247.             powerLabel.Size = UDim2.new(1, 0, 0, 30)
  248.             powerLabel.Position = UDim2.new(0, 0, 0, 0)
  249.             powerLabel.Text = "Power: " .. currentPower
  250.             powerLabel.TextColor3 = Color3.new(1, 1, 1)
  251.             powerLabel.BackgroundTransparency = 1
  252.             powerLabel.Parent = frame
  253.            
  254.             local increaseBtn = Instance.new("TextButton")
  255.             increaseBtn.Size = UDim2.new(1, 0, 0, 30)
  256.             increaseBtn.Position = UDim2.new(0, 0, 0, 40)
  257.             increaseBtn.Text = "Increase Power (E)"
  258.             increaseBtn.TextColor3 = Color3.new(1, 1, 1)
  259.             increaseBtn.BackgroundColor3 = Color3.new(0, 0.5, 0)
  260.             increaseBtn.Parent = frame
  261.            
  262.             local decreaseBtn = Instance.new("TextButton")
  263.             decreaseBtn.Size = UDim2.new(1, 0, 0, 30)
  264.             decreaseBtn.Position = UDim2.new(0, 0, 0, 80)
  265.             decreaseBtn.Text = "Decrease Power (Q)"
  266.             decreaseBtn.TextColor3 = Color3.new(1, 1, 1)
  267.             decreaseBtn.BackgroundColor3 = Color3.new(0.5, 0, 0)
  268.             decreaseBtn.Parent = frame
  269.            
  270.             -- Button events
  271.             increaseBtn.MouseButton1Click:Connect(function()
  272.                 setPower(currentPower + 0.2)
  273.                 powerLabel.Text = "Power: " .. math.floor(currentPower * 10) / 10
  274.             end)
  275.            
  276.             decreaseBtn.MouseButton1Click:Connect(function()
  277.                 setPower(currentPower - 0.2)
  278.                 powerLabel.Text = "Power: " .. math.floor(currentPower * 10) / 10
  279.             end)
  280.            
  281.             -- Keyboard controls
  282.             game:GetService("UserInputService").InputBegan:Connect(function(input)
  283.                 if input.KeyCode == Enum.KeyCode.E then
  284.                     setPower(currentPower + 0.2)
  285.                     powerLabel.Text = "Power: " .. math.floor(currentPower * 10) / 10
  286.                 elseif input.KeyCode == Enum.KeyCode.Q then
  287.                     setPower(currentPower - 0.2)
  288.                     powerLabel.Text = "Power: " .. math.floor(currentPower * 10) / 10
  289.                 end
  290.             end)
  291.         end
  292.     end
  293. end
  294.  
  295. -- Setup test controls
  296. setupTestControls()
  297.  
  298. return {
  299.     updateTrajectory = updateTrajectory,
  300.     setPower = setPower,
  301.     clearTrajectory = clearTrajectory
  302. }
Advertisement
Add Comment
Please, Sign In to add comment