I need help with a complex script

I am making a soccer game. I am currently working on the dribble system as it is broken as of now.

How I want it to work:

You will have the player character, with a part about 2 studs away from the legs. This is where the ball will be. How could I make a script that checks when the ball has been touched by another part (just the entire length, the 2 studs + the other part and the feet.) and if it has been touched, it will kind of teleport the ball to the part 2 studs away from the feet. Functioning as a sort of dribble system, I will add a little kicking animation to make it look more realistic.

This would really improve my game, and I just don’t know how I could do this.

Help is appreciated

1 Like

do you want it to attach your feet two studs infront?

1 Like

Yes. 2 studs in front

(ignore this)

local ball = script.Parent
script.Parent.Touched:Connect(function(hit)
	
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then

		ball.CanCollide = false
	local motor6d = Instance.new("Motor6D")
	motor6d.Parent = ball
	motor6d.Part0 = hit.Parent:FindFirstChild("RightLowerLeg")
	motor6d.Part1 = ball 
    motor6d.C1 = CFrame.new(0,0,2)
	
		
	

	end
end)