Part ignores my if statements?

local function onTouched(hitPart)
	if hitPart.Name ~= "Ball" and not isKicking then
		return
	end
	print(hitPart.Name)
	ToolManager:setNetworkOwner(hitPart)
	
	local kickVelocity = Instance.new("BodyVelocity", hitPart)
	kickVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	kickVelocity.Velocity = humanoidRootPart.CFrame.LookVector * power + humanoidRootPart.CFrame.UpVector * height
	
	Debris:AddItem(kickVelocity, .3)
end


rightLeg.Touched:Connect(onTouched)

I’m making a soccer ball and when I print (hitPart.Name) it prints “Baseplate” even though I added a check for the part name? It seems to be passing these if statements somehow and I’m completely lost as to why this is happening?

Ok, I figured it out, I needed to put or instead of and in the if statement. But another issue arises, my soccer ball just doesnt move at all when it was working fine even with this error?

local function onTouched(hitPart)
	if hitPart.Name ~= "Ball" or not isKicking then
		return
	end
	ToolManager:setNetworkOwner(hitPart)
	
	local kickVelocity = Instance.new("BodyVelocity", hitPart)
	kickVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	kickVelocity.Velocity = humanoidRootPart.CFrame.LookVector * power + humanoidRootPart.CFrame.UpVector * height
	
	Debris:AddItem(kickVelocity, .3)
end


rightLeg.Touched:Connect(onTouched)

(figured everything out, sorry for confusion)

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