Im trying to spawn orbs behind the player and right now I have completed that step using AlignPosition and AlignOrientation. The problem comes when trying to play an animation that makes the orbs move back and forth. I tried cloning the animation but it didn’t work. I don’t have any clue where to go from here so if you have any ideas lmk.
local Players = script.Parent.Parent.Parent
local lcPlayer = Players.LocalPlayer
local char = lcPlayer.CharacterAdded:wait()
local humr = char:WaitForChild("HumanoidRootPart")
local bob = script.Animation
local function Orb(x,y) --Spawns orb and moves it to head/ Might want to change to humanoidrootpart
local orb = Instance.new("Part") --Instances Part
orb.Shape = Enum.PartType.Ball
orb.CanCollide = false --If collide on the orb will push the user
orb.Size = Vector3.new(1,1,1)
orb.Anchored = false
orb.Parent = humr
orb.CFrame = humr.CFrame
orb.Material = Enum.Material.SmoothPlastic --makes part smooth
local humanoid = Instance.new("Humanoid")
humanoid.Parent = orb
local bobClone = bob:Clone()
bobClone.Parent = orb
local AnimationTrack = humanoid:LoadAnimation(bobClone)
if 1 ==1 then
print("Yeet")
AnimationTrack:Play()
end
local orbAttatchment = Instance.new("Attachment",orb) --Attatchment is in orb
local humrAttatchment = Instance.new("Attachment",humr) --Attatchment in head
humrAttatchment.Position = humrAttatchment.Position + Vector3.new(x,y,2)
local alignOr = Instance.new("AlignOrientation",orb) -- I think it is useless bc its a ball and doesn't really matter if it rotates
alignOr.MaxTorque = 10000
alignOr.Attachment0 = orbAttatchment
alignOr.Attachment1 = humrAttatchment
local alignPos = Instance.new("AlignPosition",orb) --Moves orb to the head attatchment
alignPos.Attachment0 = orbAttatchment
alignPos.Attachment1 = humrAttatchment
end
Orb(1,-1)
Orb(0,1)
I’m pretty certain you’re supposed to be using the Humanoid.Animator for loading the animation.
No, Hes loading the animation correctly
First of all, I would recommend using a “animation controller” instead of a humanoid for non player models. The problem could be that your animation priority is not action. Go into your animation editor and click the three dots(" . . . ") . Then Click “Set Animation priority” and change it to action.
Edit: Looking at your use case, dont use an animation, Tweening Is way more easier and better for your case.
So I don’t think that a tween will work well because im having the orb go in more of an arc form instead of back and forth as the msg implied. After changing the animation priority I tried using the animation controller but it didn’t work. This is what the code looked like after adding the animation controller
local lcPlayer = Players.LocalPlayer
local char = lcPlayer.CharacterAdded:wait()
local humr = char:WaitForChild("HumanoidRootPart")
local bob = script.Animation
local function Orb(x,y) --Spawns orb and moves it to head/ Might want to change to humanoidrootpart
local orb = Instance.new("Part") --Instances Part
orb.Shape = Enum.PartType.Ball
orb.CanCollide = false --If collide on the orb will push the user
orb.Size = Vector3.new(1,1,1)
orb.Anchored = false
orb.Parent = humr
orb.CFrame = humr.CFrame
orb.Material = Enum.Material.SmoothPlastic --makes part smooth
local animCon = Instance.new("AnimationController")
animCon.Parent = orb
local AnimationTrack = animCon:LoadAnimation(bob)
local orbAttatchment = Instance.new("Attachment",orb) --Attatchment is in orb
local humrAttatchment = Instance.new("Attachment",humr) --Attatchment in head
humrAttatchment.Position = humrAttatchment.Position + Vector3.new(x,y,2)
local alignOr = Instance.new("AlignOrientation",orb) -- I think it is useless bc its a ball and doesn't really matter if it rotates
alignOr.MaxTorque = 10000
alignOr.Attachment0 = orbAttatchment
alignOr.Attachment1 = humrAttatchment
local alignPos = Instance.new("AlignPosition",orb) --Moves orb to the head attatchment
alignPos.Attachment0 = orbAttatchment
alignPos.Attachment1 = humrAttatchment
AnimationTrack:Play()
end
Orb(1,-1)
Orb(0,1)
there aren’t any errors as well.
A tween will work even if its an arc, just make a calculation and tween to each position until you reach the end position. Are there any errors with your current code?
No there aren’t any errors with the code which is strange. I’ll try the tween but if u can think of the reason this not working lmk