Hello devs! So I am working on grab system in my game and this is my current code :
script.Parent.Events.Grab.OnServerEvent:Connect(function(player)
if not grabbedTarget then
grabbedTarget,grabbedTargetHrp = getNearestPlayerToGrab()
end
if grabbedTarget then
if grabbing == false then
grabbing = true
local weld = Instance.new("Weld",script.Parent.Head)
weld.Name = "GrabWeld"
weld.Part0 = script.Parent.Head
weld.Part1 = grabbedTargetHrp
weld.C0 = CFrame.new(0,-1.5,-3) * CFrame.Angles(0,math.rad(180),0)
grabbedTarget.Humanoid.PlatformStand = true
for _,i in pairs(grabbedTarget:GetDescendants()) do
if i:IsA("BasePart") then
ps:SetPartCollisionGroup(i,"grabbed")
i.Massless = true
end
end
else
grabbing = false
grabbedTarget.Humanoid.PlatformStand = false
for _,i in pairs(grabbedTarget:GetDescendants()) do
if i:IsA("BasePart") then
ps:SetPartCollisionGroup(i,"Default")
i.Massless = false
end
end
if script.Parent.Head:FindFirstChild("GrabWeld") then
script.Parent.Head.GrabWeld:Destroy()
end
grabbedTarget:SetPrimaryPartCFrame(hrp.CFrame)
end
end
end)
It all works fine but when I grab someone the walking animations don’t play so what’s the issue?
This seems more like an issue with your animation than your code. Could you make sure that you’ve omitted the torso and legs from the grabbing animation if there are no keyframes for them? It seems like you only intended for the animation to reposition the arms but didn’t omit other parts as well.
For the default animation editor you need to click “Delete Track” on limbs that you don’t have or need keyframes for (e.g. the legs). It’s the three dots beside each item in the parts manager. For other animation editors exclusion may vary based on implementation.
There’s another animation playing for the “grab” that is likely “Action” priority. Walking is a Movement priority. If that animation uses the same bones as walking, the grab takes precedence. Look in animation editor and remove all animation data except the 2 arms.
I’m just getting into “PlatformStand” but this might be the issue too. As I understand it, PlatformStand prevents all movement animations. You wouldn’t think it would affect the grabber, only the grabbee, but it’s worth checking. You are welding them together so the target might be affecting the player. Try commenting out setting it to true and see if that’s the culprit.
I just discovered RigidConstraint. I attached an accessory to a bone without breaking animations. Might try that instead of a weld. You can weld any 2 attachments.
I wonder if the problem is you have 2 humanoids and 2 animators? Seems like once you welded them, the active one isn’t recognized?
When I do a horseback riding animation, I combine the 2 models into one. You might need to do that here by temproarily removing the animator of the carried model.