Trying to make barrel spawn in right hand

i have a problem with my animation. my barrel wont line up properly in the hand so it’s just floating when i click the barrel. so i have this rig with a barrel in his hand. i need the barrel to spawn in that place when i click the barrel. i have a video highlighting my issue. i have a weld constraint which keeps the barrel and the righthand animatable together.

image

script so far: (this works, im just trying to get the barrel to position properly so it wont be floating)

local barrel = script.Parent
local cd = barrel.ClickDetector

cd.MouseClick:Connect(function(p)
	local hum = p.Character:WaitForChild("Humanoid")
	local animator:Animator = hum.Animator
	local barrelPickup = barrel.barrelPickup
	local barrelanimTrack = animator:LoadAnimation(barrelPickup)
	local barrelConstraint:WeldConstraint = barrel.barrelConstraint
	
	barrelConstraint.Part0 = p.Character:WaitForChild("RightHand")
	barrelConstraint.Part1 = barrel
	barrelanimTrack:Play()
	
	barrelanimTrack:GetMarkerReachedSignal("pauseAnimation"):Connect(function()
		barrelanimTrack:AdjustSpeed(0)
	end)
	
end)

You’ll want to set the CFrame of the barrel so that it’s sitting in the hand before you start playing the animation.

1 Like

hey testy, thanks a million for your help.

i tried this just now but the thing is, for my animation i randomly placed the barrel in the right hand of my rig so i think i need to put it in the same position relative to the rig’s right hand for it to properly align.

i did this and got this:

cd.MouseClick:Connect(function(p)
	local hum = p.Character:WaitForChild("Humanoid")
	local animator:Animator = hum.Animator
	local barrelPickup = barrel.barrelPickup
	local barrelanimTrack = animator:LoadAnimation(barrelPickup)
	local barrelConstraint:WeldConstraint = barrel.barrelConstraint
	
	barrel.CFrame = p.Character:WaitForChild("RightHand").CFrame
	barrelConstraint.Part0 = p.Character:WaitForChild("RightHand")
	barrelConstraint.Part1 = barrel
	barrelanimTrack:Play()
	
	barrelanimTrack:GetMarkerReachedSignal("pauseAnimation"):Connect(function()
		barrelanimTrack:AdjustSpeed(0)
	end)
	
end)

image
Try using a Weld instead of a WeldConstraint, and then set C1 so that it matches how you hold it in the animation.
Here’s how I would figure out what C1 should be:
Load the animation, and place an attachment in the barrel. Place an attachment in the hand too. Now, copy the WorldCFrame of the barrel attachment, and paste it into the WorldCFrame of the hand attachment. Then you can copy the CFrame of the hand attachment. That should give you a CFrame you can use in the C1 property of the weld between the hand and barrel.

Of course there’s probably a much easier method that I don’t know of, but it’s still better than nothing.

1 Like

that worked dang… i did some tweaks with the C0, i put the barrel worldcframe as C1 and i just tweaked the C0 as u said to what was in the animation. its perfect, tysm for ur help!! :slight_smile:

1 Like

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