Need help with TweenService issues

My friend and me are working on a boss npc fella and my friend coded this thing up but when he tried to add like tween to it, the bosses’ humanoidrootpart is being detached and fly’s away by itself.

Here’s the clip.

Here’s the function of the script:

function randomMoveToPlate()
    local ChosenPlate = game.Workspace.Map.Plates:GetChildren()[math.random(1,#game.Workspace.Map.Plates:GetChildren())]
    repeat
        wait()
        ChosenPlate = game.Workspace.Map.Plates:GetChildren()[math.random(1,#game.Workspace.Map.Plates:GetChildren())]
    until ChosenPlate.Name ~= "Map"
    local minX = -ChosenPlate.Part.Size.X / 2 - 12
    local maxX = ChosenPlate.Part.Size.X / 2 + 12
    local minZ = -ChosenPlate.Part.Size.Z / 2 - 12
    local maxZ = ChosenPlate.Part.Size.Z / 2 + 12
    local minY = -ChosenPlate.Part.Size.Y / 2
    local maxY = ChosenPlate.Part.Size.Y / 2 + 50
    local pos = ChosenPlate.Part.Position + Vector3.new(math.random(minX,maxX),math.random(minY,maxY),math.random(minY,maxY))
    local Cpos = ChosenPlate.Part.CFrame * CFrame.new(math.random(minX,maxX),math.random(minY,maxY),math.random(minY,maxY))
    --script.Parent:SetPrimaryPartCFrame(CFrame.lookAt(script.Parent.Torso.Position, pos))
    tw:Create(script.Parent.HumanoidRootPart, TweenInfo.new(speed.Value, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Position = pos}):Play()
end
2 Likes

Hey Tarf!

There are multiple reasons why this might have happened.

  1. Your humanoid root part is not connected to the body (with Motor6 or any Weld)
  2. Something other than HumanoidRootPart in your body is anchored, so the weld dependencies doesn’t work

However, it is not a good practice to tween the body like that in the first place. You should either use a CFrame to move, or even better, use a :PivotTo() function on the whole body model.

Hope that helps!

1 Like

Hey, thanks for replying!

I’m going to try these solutions and I will tell you if they work or not.

The issue is fixed! thanks for the help man.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.