So i have this animation that has a custom rig(basically added the gloves to the rig and thats it) but know when i play that animation it need the player to also have that same animation object and i dont know how to get it to the player and i need some help
Heres the animation i have, its for when the player equips the tool
If the gloves are a tool like you said just place the tool in the StarterPack? Detect when the tool is equipped with [ToolInstance].Equipped and load the animation into the animator of the humanoid (Humanoid.Animator) of the parent of the tool (character). like so:
Place your gloves/animation object into StarterPack
Place a script into the tool
Detect when the tool is equipped in the script
local Tool = script.Parent -- local variable to define the tool
local function detectEquip() -- function that runs on equip
end
Tool.Equipped:Connect(detectEquip)
Play the animation when the function runs
local Tool = script.Parent -- local variable to define the tool
local function detectEquip() -- function that runs on equip
local character = Tool.Parent -- finds the character
local hum = character:FindFirstChildOfClass("Humanoid") -- checks if character has a humanoid
local animation = Instance.new("Animation") -- creates an animation instance
animation.Parent = script -- parents the instance to this script
animation.AnimationId = "rbxassetid://YOUR_ANIMATION_ID" -- replace YOUR_ANIMATION_ID with ID you can copy when you click the three dots next to the animation name and Publish to Roblox inside Animation Editor
if hum then -- checks if the character is a character by checking if it has a humanoid
local anim = hum:WaitForChild("Animator"):LoadAnimation(animation) -- loads the animation into Humanoid.Animator, the animator of the humanoid
anim.Priority = Enum.AnimationPriority.Action -- sets the animation priority to avoid issues
anim.Looped = false -- unloops it so it doesnt play constantly
anim:Play() -- plays the animation
end -- ends block to avoid errors
end -- ends block to avoid errors
Tool.Equipped:Connect(detectEquip) -- runs the function on equip
so i just checked and i have a tool version of the gloves and the one on the rig are just models that have motor 6d, should/do i need to reanimate this but instead of the model with motor 6d i make it the tool with motor 6d?
Have you by chance seen the How to Animate Parts of a Tool? If so I think you’re going to have to put the tool in the model and reanimate using that tutorial if you havent i’ll send a link
I have! but i need some more explanation since i want to connect each glove onto the each arm, but in the tutorial it only connects to the torso so i wasnt able to follow up on that
You could just make weldconstraints for each arm and glove…
I have a method, but can you share the properties of the Motor6Ds? I will know exactly what to do then. Specifically C0 Position Orientation and C1 Position Orientation and Part0 and Part1.
Sooooo i have two models, one where the glove model is rigged to be connected to the body, and a second with the glove tool instead of just the model, and it has a motor6d on each arm and connected to each glove
Mb i forgot to ask as well as the positions of the Right Arm and Left Arm of the Rig. That will give me information on how to set this up and how to create the offset. sorry for forgetting I’ll get started on this though
And the positions of the meshes with motor6ds in the rig
– 2. Take the Cube and Cube.001 meshes out of the tool and put them in a folder called “Meshes” in ReplicatedStorage. Rename Cube.001 to Cube001
– 3. Use a server script inside the tool to weld the meshes to the hands after the animation plays and unweld when it ends
– ```
local Tool = script.Parent
local character = Tool.Parent
local meshes = game:GetService(“ReplicatedStorage”):WaitForChild(“Meshes”)
local animation = Instance.new(“Animation”)
animation.Parent = script
animation.Name = "EquipAnim"
animation.AnimationId = "rbxassetid://YourAnimIdAfterPublishingToRoblox" -- change
if character:IsA("Model") and character:FindFirstChild("Humanoid") then
Tool.Equipped:Connect(function(idk)
local antrac = character:FindFirstChild("Humanoid").Animator:LoadAnimation(animation)
local DS = game:GetService("DebrisService")
local c = meshes.Cube:Clone()
local c2 = meshes.Cube001:Clone()
c.CFrame.Position = character:FindFirstChild("Right Arm").CFrame.Position + Vector3.new(0.068, -0.479, 0.035)
c.CFrame.Rotation = Vector3.new(0, -180, 0)
c2.CFrame.Position = character:FindFirstChild("Left Arm").CFrame.Position + Vector3.new(0.028, -0.479, 0.035)
c2.CFrame.Rotation = Vector3.new(0, -180, 0)
c.Parent = character
c2.Parent = character
local m1 = Instance.new("Motor6D")
m1.Name = "Joint"
m1.Parent = c
m1.C0.Position = character:FindFirstChild("Right Arm").CFrame:Inverse()
m1.C0.Orientation = CFrame.new(0, -180, 0)
m1.Part0 = character:FindFirstChild("Right Arm")
m1.Part1 = c
local m2 = Instance.new("Motor6D")
m2.Name = "Joint"
m2.Parent = c2
m2.C0.Position = character:FindFirstChild("Left Arm").CFrame:Inverse()
m2.C0.Orientation = CFrame.new(0, -180, 0)
m2.Part0 = character:FindFirstChild("Left Arm")
m2.Part1 = c2
antrac.Looped = false
antrac:Play()
DS:AddDebris(m2, antrac.AnimationLength)
DS:AddDebris(m1, antrac.AnimationLength)
DS:AddDebris(c, antrac.AnimationLength)
DS:AddDebris(c2, antrac.AnimationLength)
antrac.Stopped:Connect(function(e)
local clone = meshes.Cube:Clone()
clone.Parent = Tool
clone.Position = character:WaitForChild("Right Arm").CFrame.Position + Vector3.new(0.068, -0.479, 0.035) -- !IMPORTANT! change #, #, # to something else if the gloves are off !IMPORTANT!
local weld = Instance.new("WeldConstraint")
weld.Parent = clone
weld.Part0 = character:WaitForChild("Right Arm")
weld.Part1 = weld.Parent
local clone2 = meshes.Cube001:Clone()
clone2.Parent = Tool
clone2.Position = character:WaitForChild("Left Arm").CFrame.Position + Vector3.new(0.028, -0.479, 0.035) -- !IMPORTANT! change #, #, # to something else if the gloves are off !IMPORTANT!
local weld2 = Instance.new("WeldConstraint")
weld2.Parent = clone2
weld2.Part0 = character:WaitForChild("Left Arm")
weld2.Part1 = weld.Parent
end)
end)
end
Tool.Unequipped:Connect(function(thingy)
Tool:FindFirstChild("Cube001"):Destroy()
Tool:FindFirstChild("Cube"):Destroy()
end)