Goalkeeper limited targeting area problem

Hello, everyone

I trying to make goalkeeper ball targeting system like this:

But when i tested out my targeting system i getting this:

I tried to add some boolean checks but its not helped at all

Theres a block of code that i have issue with:

	local ballPos: Vector3 = ballModel:GetPivot().Position
	local primaryPos: Vector3 = self.Model.PrimaryPart.Position
	local homePos: Vector3 = self.homePosition.Position

	if (ballPos - primaryPos).Magnitude <= 40 and BallController:GetBallPhysic().resting then
		self:InterceptBall()
	end

	if (ballPos - primaryPos).Magnitude <= self.catchRange then 
		self:InterceptBall()
	else
		if BallController:GetCaptured() ~= "" then
			if (self.homePosition.Position - primaryPos).Magnitude > 15 then
				self.Model:PivotTo(self.homePosition)
				return
			end
				
			local ballZPos = ballPos.Z

			local faceCf = CFrame.new(primaryPos.X, primaryPos.Y, ballZPos)

			local finalCf = faceCf * CFrame.Angles(0, math.rad(90), 0)

			self.Model:PivotTo(finalCf)
		end
	end

Is the issue how the screen shot is repeating ? What is self ? Is self the ball Model ?

What is happening in your GetCaptured() function ? You are capturing screen shots ?

Huh? No, function “GetCaptured” getting current handler of the ball

OOP construction for my module

No, self is the goalkeeper module

I am referring to this in your if statement, What is this ?

Ok so what is going wrong, I’m not exactly sure based on your video snippet supplied?

I assume you’re trying to get the keeper to stay within the bounds of the net, so use math.clamp() to clamp the position of the goalkeeper within the bounds of the net, your code seems to find the final position the keeper should be, and if its out of the net bounds, you just reset the keepers cframe to the home position, so instead of that, just clamp the final cframe

1 Like

Is this code running inside a loop, hence the repeating frame on the screen.
Is the model Pivoting each frame ? Is the camera following that model ?

Oh i tryed it out and its works! Thanks a lot

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.