1. repeat wait() until workspace:FindFirstChild("Ball")
  2. -- Constants
  3. local UserInputService = game:GetService("UserInputService")
  4. local RunService = game:GetService("RunService")
  5. -- Marker
  6. local Marker = Instance.new("Part")
  7. Marker.Name = "Marker"
  8. Marker.Size = Vector3.new(2, 2, 2)
  9. Marker.Shape = Enum.PartType.Ball
  10. Marker.BrickColor = BrickColor.new("Bright violet")
  11. Marker.CanCollide = false
  12. Marker.Anchored = true
  13. Marker.Parent = workspace
  14. Marker.Transparency = 1
  15. Marker.Material = Enum.Material.Neon
  16. -- Physics
  17. local function PHYSICS_STUFF(velocity, position)
  18. local acceleration = -workspace.Gravity
  19. local timeToLand = (-velocity.y - math.sqrt(velocity.y * velocity.y - 4 * 0.5 * acceleration * position.y)) / (2 * 0.5 * acceleration)
  20. local horizontalVelocity = Vector3.new(velocity.x, 0, velocity.z)
  21. local landingPosition = position + horizontalVelocity * timeToLand + Vector3.new(0, -position.y, 0)
  22. return landingPosition
  23. end
  24. -- Construct
  25. RunService:BindToRenderStep("VisualizeLandingPosition", Enum.RenderPriority.Camera.Value, function()
  26. Marker.Transparency = 0.5
  27. for _, ballModel in ipairs(workspace:GetChildren()) do
  28. if ballModel:IsA("Model") and ballModel.Name == "Ball" then
  29. local ball = ballModel:FindFirstChild("BallPart")
  30. if ball then
  31. local initialVelocity = ballModel.Velocity
  32. local landingPosition = PHYSICS_STUFF(initialVelocity.Value, ball.Position)
  33. Marker.CFrame = CFrame.new(landingPosition)
  34. end
  35. end
  36. end
  37. end)