How to animate an R6 Rig with an object

I got this error:
Players.Nifemiplayz.Backpack.RedFlagtest.Mechanics:29: attempt to index nil with ‘Parent’

Alright. So, could you PM me a file for the game and let me fix it there? I’m probably needing to run trials so it actually works the way we need to attend it.

Ok here:
FlagThrowingTest.rbxl (72.9 KB)

Alright, this should work.

UIS = game:GetService("UserInputService")

script.Parent.Equipped:Connect(function()

	local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
	local Animation = script.Parent.ThrowAnimation
	local flagPole = script.Parent.Handle
	
	if Humanoid and Humanoid.Health > 0 then

		local Animator = Humanoid:FindFirstChild("Animator") or Humanoid
		local PlayAnim = Animator:LoadAnimation(Animation)
		
		UIS.InputBegan:Connect(function(Input)

			if Input.KeyCode == Enum.KeyCode.Q then

				PlayAnim:Play()

				PlayAnim:GetMarkerReachedSignal("ThrowSpear"):Connect(function()
					
					script.Parent.Parent = workspace
					wait()
					local bodyVelo = Instance.new("BodyVelocity")

					bodyVelo.MaxForce = Vector3.new(1,0,1) * 30000
					bodyVelo.Velocity = flagPole.CFrame.RightVector * -150
					bodyVelo.Parent = flagPole
					
					script.Parent.Parent = workspace
					flagPole.CanTouch = false
					wait(0.6)
					bodyVelo:Destroy()
					flagPole.CanTouch = true
				end)
			end
		end)
	end
end)

We needed to do RightVector since the cylinders bottom end is actually to the left of it.

And I just changed from finding the touch interest since it gives and error and for some reason doesn’t actually destroy it, to just making the handle of the tool not touchable for a little bit.

@Nifemiplayz, I hope this helps. If you want, you can mark it as solution. Doesn’t really matter

When i move while throwing it i get pushed in certain directions. And the spear isnt thrown how i expected it to be. I wanted it to be thrown like a logical spear where the spear is facing forward and curves down as gravity works on it. Is there a way to do this?:

Maybe change the MaxForce to 1,1,1

I don’t think velocity was the best way to approach this. I want the spear throwing to be something like throwing a spear realistically, when you throw it it goes slightly up and come back down to hit the floor

Make the velocity of Y bigger. Maybe that’ll help

I already found another article what I was looking for was curved trajectorys. Thank you for your help though

1 Like