So I welded every parts in the model and wrote this simple script:
local humanoid = player.Character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(script.Animation)
animationTrack.Looped = true
animationTrack.Priority = Enum.AnimationPriority.Action
animationTrack:Play()
local hmr = player.Character.HumanoidRootPart
for i,v in pairs(bit:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = false
v.CanCollide = false
end
end
bit.LevitateScript.Disabled = true
while true do
bit:SetPrimaryPartCFrame(hmr.CFrame+hmr.CFrame.lookVector*3)
wait(0.005)
end
But it didn’t turn out so well, It flings the model like this: https://gyazo.com/0e313811e75a9cceecf55425a72dbfbb
I was very confused because there were no errors in output, so I tried another way which is welding Bit (the model) to player’s torso.
local humanoid = player.Character:WaitForChild("Humanoid")
local animationTrack = humanoid:LoadAnimation(script.Animation)
animationTrack.Looped = true
animationTrack.Priority = Enum.AnimationPriority.Action
animationTrack:Play()
local hmr = player.Character.HumanoidRootPart
bit:SetPrimaryPartCFrame(hmr.CFrame+hmr.CFrame.lookVector*3)
for i,v in pairs(bit:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = false
v.CanCollide = false
local weld = Instance.new("Weld")
weld.Parent = player.Character.Torso
weld.Part0 = player.Character.Torso
weld.Part1 = v
end
end
Doing this with a single part or a mesh would be much easier, but you can also weld (using the new weld constraints) all of the parts to a single root part and then only move the root part. All the parts that are welded to the root part should be unanchored.
So what I need to do is, weld all the parts in my model to a single part, then move that single part to the front of the player and then weld it to the player’s humanoid root part?
Yes, weld all of the parts (using a WeldConstraint) to a single part, make sure all of the welded parts are unanchored, and then only manipulate the main part.
Make sure you unanchor the main part as well once you pick it up. For best effect, make sure that all of the “Massless” options are checked in the properties.
Thank you so much sir, it works as I expected now, but there’s a little problem. The positioning of the model is incorrect. https://gyazo.com/3917acc88034d74ab7b482c021308d01
This is the code I wrote for positioning: