Help with basketbal Dribbling System

So I’m makin game basketball game and i have a dribbling system that depends on what key u press and what hand the ball in and this move I’ working on is a move where if the ball ins in ur left hand and u press z it will do one move and if the ball is in your right hand and you press z you do another move. But when I press z and the ball is in my Right hand it’s not working but the move witht he left hand works completely fine. My code is below can someone please help me

local function Iso(Combos,Isoing)
	print(Combos)
	print(Hand)
	if not Character:FindFirstChild("Attach") or not _G.Debounce or not _G.BallDebounce or not CanDribble then return end  
	Humanoid.AutoRotate = false 
	Humanoid.WalkSpeed = 0 
	local Goal = GetGoal(HumanoidRootPart)
	Gyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
	Gyro.Parent = HumanoidRootPart
	Gyro.CFrame = CFrame.new(HumanoidRootPart.Position,Vector3.new(Goal.Position.X,HumanoidRootPart.Position.Y,Goal.Position.Z))
	BVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	BVelocity.P = 1820 
	BVelocity.Parent = HumanoidRootPart
	if not Isoing then  repeat wait() until (Character.LeftHand.Position - Ball.Position).magnitude < 1 or 1 > (Character.RightHand.Position).magnitude end 
	_G.Debounce = false
	_G.BallDebounce = false 
	if Combos == "z" then 
		if Hand == "L" then
			BVelocity.Velocity = -(HumanoidRootPart.CFrame.rightVector*6)
			Animations.InOutL.KeyframeReached:Connect(function(KeyFrame)
				if KeyFrame == "Out" then
					BVelocity.Velocity =   (HumanoidRootPart.CFrame.rightVector*11)

				else if KeyFrame == "In" then
						BVelocity.Velocity = -(HumanoidRootPart.CFrame.rightVector*13)
					end
				end
			end)
			Animations.InOutL:Play(0.2)
			wait(Animations.InOutL.Length)
			Animations.InOutL:Stop(0.2)
			
			
		else if Hand == "R" then print("R")
				BVelocity.Velocity = (HumanoidRootPart.CFrame.rightVector*6)
				Animations.CrossoverL.KeyframeReached:Connect(function(KeyFrame)
					if KeyFrame == "Out" then
						BVelocity.Velocity = -(HumanoidRootPart.CFrame.rightVector*13)
						Hand = "L"
					end
				end)
				Animations.CrossoverL:Play(0.2)
				wait(Animations.CrossoverL.Length)
				Animations.CrossoverL:Stop(0.2) 
		end
	end	
	--else if Combos == "zx" then
			
		--end
	end
	BVelocity.Parent = nil 
	Gyro.Parent = nil 
	Humanoid.AutoRotate = true 
	Humanoid.WalkSpeed = MoveSpeed
	_G.Debounce = true
	_G.BallDebounce = true 
end```
1 Like

found my issue!!! I did this

if not Isoing then  repeat wait() until (Character.LeftHand.Position - Ball.Position).magnitude < 1 or 1 > (Character.RightHand.Position).magnitude end 

instead of this

if not Isoing then  repeat wait() until (Character.LeftHand.Position - Ball.Position).magnitude < 1 or 1 > (Character.RightHand.Position-Ball.Position).magnitude end 

Basically I didn’t get the magnitude of the right hand minus the ball typing error…

2 Likes