Animating parts relative to player

I’m currently working on an homage to Dark Souls’ Homing Soulmass. For those who are unaware, this spell summons five orbs in an arc above the player’s head. These orbs follow the player in this formation, staying in an arc at a fixed position above their head, until they’re fired off. I’ve thrown together an animation illustrating how the initial summon should look:

I accomplished this by creating a handle (named BodyAttach) that I inserted into the character and using a Motor6D to bind it to the HumanoidRootPart. I also added each of the five orbs to the character model, using separate Motor6Ds to bind them to BodyAttach. This works fine in the context of animating a dummy, but my question pertains to the concept of animating parts relative to a player at large.

Although I’ve managed to accomplish this in an isolated environment, I’m unsure of how to actually apply this animation to someone playing the game. Currently, I’m repeating the above steps (adding BodyAttach and the orbs to the character model, along with all necessary Motor6Ds) before loading the animation, but the animation does not take effect nor yield an error. My rough code for accomplishing this is as follows:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local character = script.Parent
local humanoid = character.Humanoid
local root = character.HumanoidRootPart
local animator = humanoid.Animator

local orbCopy = ReplicatedStorage.Orb -- The orbs are simple parts retrieved from ReplicatedStorage

local bodyAttach = Instance.new("Part")
bodyAttach.Parent = character
bodyAttach.Name = "BodyAttach"
bodyAttach.CanCollide = false
bodyAttach.Massless = true
bodyAttach.Transparency = 1
bodyAttach.Size = Vector3.new(1, 1, 1)

local bodyAttachMotor = Instance.new("Motor6D")
bodyAttachMotor.Parent = root
bodyAttachMotor.Name = "BodyAttachMotor"
bodyAttachMotor.Part0 = bodyAttachMotor.Parent
bodyAttachMotor.Part1 = bodyAttach

for i = 1, 5 do
	local orb = orbCopy:Clone()
	orb.Parent = character
	
	local motor = Instance.new("Motor6D")
	motor.Parent = bodyAttach
	motor.Part0 = motor.Parent
	motor.Part1 = orb
end

local orbAnimation = Instance.new("Animation")
orbAnimation.AnimationId = "rbxassetid://6856856576"
local orbAnimationTrack = animator:LoadAnimation(orbAnimation)

wait(5) -- Temporary delay for testing purposes

orbAnimationTrack:Play()

As mentioned, attempting to play this animation does nothing. This boils down to a few questions on my mind:

  1. Is my approach of creating a handle (attached by a Motor6D to the HumanoidRootPart) to which all other parts are attached correct?

  2. If so, what might I be doing incorrectly? Otherwise, how else would I go about achieving this?

I appreciate the help.

I know this isn’t on topic but just wanted to say this gives naruto vibes for me personally

1 Like

I forgot to mention that, for testing purposes, this is all being done locally (in a script placed in StarterCharacterScripts). I suppose it’s possible that I need to do something else on the server end, so this information may be useful.

Turns out I just had to name the orbs exactly as I did when creating the animation.

2 Likes