-- // Credit : DownInDaNang local ReplicatedStorage = game:GetService("ReplicatedStorage") local LocalPlayer = game:GetService("Players").LocalPlayer local GetCupLocation = ReplicatedStorage:WaitForChild("Functions"):WaitForChild("GetCupLocationFunction") local TargetCupPos: Vector3? = nil local function UpdateHoleLocation(): () local CurrentHole: number = LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Hole").Value local HoleString: string = string.format("%03d", CurrentHole) local CourseModel: any = workspace:FindFirstChild("9HoleCourse") local CupPos: any, CupData: any = GetCupLocation:InvokeServer(HoleString, CourseModel and CourseModel.Name or nil) if typeof(CupPos) == "Vector3" then TargetCupPos = CupPos end end LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Hole").Changed:Connect(UpdateHoleLocation) task.spawn(UpdateHoleLocation) local OldNewIndex: any OldNewIndex = hookmetamethod(game, "__newindex", function(Self: any, Index: string, Value: any): any if not checkcaller() and (Index == "AssemblyLinearVelocity" or Index == "Velocity") and Self:IsA("BasePart") and Self.Name:find("Ball") then if TargetCupPos then local DeltaPos: Vector3 = (TargetCupPos - Self.Position) local HorizontalDist: number = Vector3.new(DeltaPos.X, 0, DeltaPos.Z).Magnitude if HorizontalDist > 0.5 then local TimeToTarget: number = math.clamp(HorizontalDist / 30, 0.4, 1.2) local Gravity: number = 35.037 -- grav local AimVelocity: Vector3 = Vector3.new( DeltaPos.X / TimeToTarget, (DeltaPos.Y + 0.5 * Gravity * TimeToTarget^2) / TimeToTarget, DeltaPos.Z / TimeToTarget ) return OldNewIndex(Self, Index, AimVelocity) end end end return OldNewIndex(Self, Index, Value) end)