2
votes

I'm currently working on a game on ROBLOX that contains a TON of NPC's. I need a way to make the player not be able to move them around in any way. I've tried anchoring the HumanoidRootPart, and that worked, but it made the NPC unable to move.

Can anyone help?

3

3 Answers

1
votes

You could weld the NPC to the ground, if possible.

This could work:

local weld = Instance.new("WeldConstraint")
weld.Part0 = part
weld.Part1 = otherPart
weld.Parent = part

There is more info here on welding.


If you don't need players to clip through said NPCs, you could "unclip" the NPC, allowing players to move through it but not move it.

local function setDescendantCollisionGroup(Descendant)
    if Descendant:IsA("BasePart") and Descendant.CanCollide then
        -- set collision group
    end
end

model.DescendantAdded:Connect(setDescendantCollisionGroup)
for _, descendant in pairs(model:GetDescendants()) do
    setDescendantCollisionGroup(descendant)
end
0
votes

This should be able to be done using a property . Create a startercharacter so players wear this character,and then modify it's customphysicalproperties "friction" , "density" to a very low number.

You should also be able to put such in a script such as when a player join,the children with class "Part" have their density and friction low.

0
votes

Try something like this:

    local NPC = workspace.NPC --The NPC variable
    NPC.HumanoidRootPart.Mass = 69420

It should make the NPC alot heavier!
And when you want it to move:

    local NPC = workspace.NPC --The NPC variable
    NPC.HumanoidRootPart.Mass = 10

That will make the NPC lighter!
So this is the final script:

    local NPC = workspace.NPC --The NPC variable
    local humanoid = NPC:WaitForChild('Humanoid') --NPC's humanoid
    local hrp = NPC.HumanoidRootPart --NPC's HumanoidRootPart
    
    local mass1 = 69420
    local mass2 = 10
    
    humanoid.Running:Connect(function(speed)
        if speed > 0.001 then
            hrp.Mass = mass2
        else
            hrp.Mass = mass1
        end
    end)

Make sure to write that code in a ServerScript!
And put the Script inside the NPC if you want.