Hey I made a script where an item weld to the npc’s hand while the animation is playing but it doesnt work in the animation and im not sure why, can anyone help?
Also its a teddy bear and the parts are anchored
Heres the script
local playButton = script.Parent
local camera = workspace.CurrentCamera
local rig = workspace.Boy
local teddyBear = workspace.Teddy
local animationId = "rbxassetid://136167262745204"
local animationSpeed = 0.25
local function playCutscene()
playButton.Visible = false
local humanoid = rig:FindFirstChild("Humanoid")
if humanoid then
humanoid.PlatformStand = true
end
local originalCFrame = camera.CFrame
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = workspace.CutsceneCamera.CFrame
local animator = humanoid:FindFirstChild("Animator")
if animator then
local animation = Instance.new("Animation")
animation.AnimationId = animationId
local track = animator:LoadAnimation(animation)
track:AdjustSpeed(animationSpeed)
track:GetMarkerReachedSignal("GrabTeddy"):Connect(function()
if teddyBear:IsA("Model") and teddyBear.PrimaryPart then
local teddyPrimary = teddyBear.PrimaryPart
local leftHand = rig:FindFirstChild("LeftHand")
if leftHand and leftHand:IsA("BasePart") then
for _, part in pairs(teddyBear:GetDescendants()) do
if part:IsA("BasePart") then
part.Anchored = false
end
end
teddyPrimary.CFrame = leftHand.CFrame * CFrame.new(0, -0.5, 0)
local weld = Instance.new("WeldConstraint")
weld.Part0 = teddyPrimary
weld.Part1 = leftHand
weld.Parent = teddyPrimary
print("WeldConstraint created and parented successfully!")
else
warn("LeftHand not found or is not a valid BasePart!")
end
end
end)
track:Play()
track.Stopped:Wait()
end
camera.CameraType = Enum.CameraType.Custom
camera.CFrame = originalCFrame
playButton.Visible = true
end
playButton.MouseButton1Click:Connect(playCutscene)