How can i add raycast to bodyforce

how can i make a raycasting that detects walls when i’m using bodyforce so it can stop and i dont get fling here is my bodyforce im using it in an animation event:

animation:GetMarkerReachedSignal("swing"):Connect(function()
		local velocity = Instance.new("BodyVelocity",root)
		velocity.MaxForce = Vector3.new(1,1,1) * 100000000000000;
		velocity.Parent = root
		velocity.Velocity = Vector3.new(1,1,1) * root.CFrame.LookVector * 37.5
		game.Debris:AddItem(velocity,.1)
	end)

Create a ray that uses raycastparams which ensures that it only Includes walls in array to detect.Then if the ray operation has a result then remove the bodyforce otherwise do nothing about the body force.

thanks i had some errors but they are fixable anyways it worked

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