#Custom NPC cloning issue

1 messages · Page 1 of 1 (latest)

fallen mango
#

I have a Custom NPC that moves through a maze and splits into two NPCs when it gets to an intersection. However, when the clone is made, it flips out and flips upside down on the floor and doesn't run its script

#

here is a video

#

Here is the Split Function

local function Split()
local SplitType = TargetNode.Value:WaitForChild("SplitType").Value
local Node = Ronald.TargetNode.Value
local CloneNextTarget = Ronald.Parent.Nodes:WaitForChild(tostring(Node:WaitForChild("NextNode2").Value))

if SplitType == 1 then
    Ronald.HumanoidRootPart.Anchored = true
    print("Spliting Left Right")
    SquarePreSplit:Play()
    wait(SquarePreSplit.Length)
    
    local Clone = Ronald:Clone()
    Clone.HumanoidRootPart.Anchored = true
    Clone:PivotTo(Ronald:GetPivot())
    Clone.Parent = Ronald.Parent
    Clone:WaitForChild("AI").Enabled = false

    local CAnimator = Clone:WaitForChild("Humanoid"):WaitForChild("Animator")
    local CAnimation = Clone:WaitForChild("Humanoid"):WaitForChild("SquareSplitRight")
    
    CAnimator:LoadAnimation(CAnimation):Play()
    SquareSplitLeft:Play()
    wait(SquareSplitLeft.Length)
    Clone.HumanoidRootPart.Anchored = false
    Ronald.HumanoidRootPart.Anchored = false

    Clone:WaitForChild("TargetNode").Value = CloneNextTarget
    Clone:WaitForChild("AI").Enabled = true
    
elseif SplitType == 2 then
    SquarePreSplit:Play()
    wait(SquarePreSplit.Length)
    SquareIdel:Play()
    local Clone = Ronald:Clone()
    Clone.HumanoidRootPart.Anchored = true
    Clone:PivotTo(Ronald:GetPivot())
    Clone.Parent = Ronald.Parent
    Clone:WaitForChild("AI").Enabled = false
    wait(0.01)
    Clone.HumanoidRootPart.Anchored = false

    local CAnimator = Clone:WaitForChild("Humanoid"):WaitForChild("Animator")
    local CAnimation = Clone:WaitForChild("Humanoid"):WaitForChild("SquareSplitRight")
    CAnimator:LoadAnimation(CAnimation):Play()
    wait(SquareSplitLeft.Length)
    Clone:WaitForChild("TargetNode").Value = CloneNextTarget
#

elseif SplitType == 3 then
SquarePreSplit:Play()
wait(SquarePreSplit.Length)
SquareIdel:Play()
local Clone = Ronald:Clone()
Clone.HumanoidRootPart.Anchored = true
Clone:PivotTo(Ronald:GetPivot())
Clone.Parent = Ronald.Parent
Clone:WaitForChild("AI").Enabled = false
wait(0.01)
Clone.HumanoidRootPart.Anchored = false

    local CAnimator = Clone:WaitForChild("Humanoid"):WaitForChild("Animator")
    local CAnimation = Clone:WaitForChild("Humanoid"):WaitForChild("SquareSplitLeft")
    CAnimator:LoadAnimation(CAnimation):Play()
    wait(SquareSplitLeft.Length)
    Clone:WaitForChild("TargetNode").Value = CloneNextTarget
    
end

end

#

and the move function

local function MoveToNode()

SquareIdel:Stop()
SquareMove:Play()

local Node = Ronald.TargetNode.Value

local Distance = 100

while Distance > 7.5 do
    
    Distance = math.abs((Node.Position - Ronald.HumanoidRootPart.Position).Magnitude)
    print("Distance: " .. tostring(Distance))
    
    Hum:MoveTo(Node.Position)
    Hum.MoveToFinished:Wait()
    
end

print("Got To Node")

end

fallen mango
#

can someone please help?

distant trailBOT
#

studio** You are now Level 1! **studio

pliant field
fallen mango
#

I made a collision group for Ronald's humanoid root part that won't collide with others, and gave him a custom collision group part as a floor in case he was colliding with the map

#

he wont collide with anything but this one part

pliant field
#

just incase if his arms collide with the arms of another ronald maybe

fallen mango
#

they currently are set to not collide but i can try

fallen mango
#

I figured out that they are upside down since i forgot to enable their AI after spliting on certain intersections

#

I still need to stop them from phasing throught the floor

fallen mango
#

I have isolated my issue to the fact that the hip height is not used for the first 5 seconds after the clone spawns causing the humanoid root part to fall to the ground making the npoc phase throught the ground