I’ve been experiencing this bug for quite a while now… But it happens so rarely, I can almost never test to see if it’s fixed or not, what the cause might be, etc.
-
What do you want to achieve? Fix the broken NPCs to walk normally like the others
-
What is the issue? Sometimes (Very rarely) one of the NPCs can get stuck in the air right after spawn. Nothing is anchored, and there isn’t a single error.
-
What solutions have you tried so far? I’ve searched the entire dev forums for a solution, and the only thing I found remotely close to this issue was still left unsolved… So I’m here to ask for anyone’s help who might know what could be causing the issue.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here is how I spawn the NPCs
--create clone
local npc = rep.NPCs.TestNPC:Clone()
npc.Parent = spot.Visitors
local success = false
if npc:FindFirstChild("Humanoid") then--has humanoid
local speed = rep.NPCs.TestNPC.Humanoid.WalkSpeed
npc.Humanoid.WalkSpeed = math.random(speed*100*.75,speed*100*1.25)/100
success = pcall(function()
local id = friendIDs[math.random(1,#friendIDs)]
npc.Name = game.Players:GetNameFromUserIdAsync(id)
local desc = game.Players:GetHumanoidDescriptionFromUserId(id)
npc.Humanoid:ApplyDescription(desc)
for i,v in pairs(npc:GetChildren())do--destroy layered clothing
if v:IsA("Accessory") then
for i,t in pairs(layeredClothingClasses)do
if v.AccessoryType == Enum.AccessoryType[t] then
v:Destroy()
break
end
end
end
end
end)
end
if success then--successfuly set humanoid desc
startWalk(points,npc)--walk function
spawn(function()
antiCollideCharacter(npc)--avoid walking into eachother
end)
else--if not, destroy
npc:Destroy()
end
Heres how I move them:
function startWalk(points,npc)
local char = player.Character
if dist > max then--destroy cuz walkpoint too far
npc:Destroy()
else
local at = startPoint
local human = npc:WaitForChild"Humanoid"
local walk = human.Animator:LoadAnimation(npc.Anims.WalkAnim)
local think = human.Animator:LoadAnimation(npc.Anims.Think)
local sit = human.Animator:LoadAnimation(npc.Anims.SitAnim)
npc:SetPrimaryPartCFrame(CFrame.new(at.Position+Vector3.new(0,human.HipHeight+npc.PrimaryPart.Size.Y/2-at.Size.Y/2+1,0)))
wait()
walk:Play(nil,nil,human.WalkSpeed/6)
human.MoveToFinished:Connect(function(reached)
end)
human:MoveTo(at.Position)
end
end
If anyone can help it would be very appreciated!