Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Whenever I spawn NPCs, the body clips through the torso. Why does this happen and how can I fix it?

Asked by 5 years ago

NOTE: The NPCs talked about in this question are free models that involve movement and have options for teams, friendly-fire, respawning, etc...

I have two NPCs for testing the problem. The main one is an over-sized NPC and the other is a normal sized one. Originally it only happened to the over-sized NPC, but yesterday(February 12, 2019) it decided to spread to the normal sized one and got a bit worse.

My main concern is with the over-sized NPC

First things first, how do I spawn in NPCs? I spawn in NPCs by pressing "f". This spawns them 3 positive studs in the y-axis and 3 positive studs in the z-axis relative to the players torso. Now when I'm in the studio and not playing solo or testing on studio servers, the arms and legs look great and are where they're suppose to be(which is on both sides of the torso for the arms and below the torso for the legs). Now this is where it gets confusing...

NOW WHEN I DO DECIDE TO PLAY SOLO OR GO ON A TEST SERVER, the legs for the over-sized NPC move up into the torso (half of the leg is inside the over-sized NPC and both legs move closer to each other. both legs are still entirely visible). Not only that but they also move along a non-existent invisible block that is about head height(This only happens with the over-sized NPC). That's it for the over-sized one, onto the normal one. The normal one's arms move 1 stud into the torso while the legs move up 1 stud into the torso. The arms and legs are still entirely visible. This also happens to every single NPC I decide to spawn in. Here's a picture of my problem. https://imgur.com/a/asWC6tI <---- Let me know if it's working

NOTE: This issue still happens when I try to create my own basic, less complicated version of the NPC

FilteringEnabled is On

Here's the Code:

local script

local replicatedStorage = game:GetService("ReplicatedStorage")
--local createPartEvent = replicatedStorage:WaitForChild("SpawnBrick")
--local particlesEvent = replicatedStorage:WaitForChild("Light")
local createNPC = replicatedStorage:WaitForChild("NPC")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

    print("DoesItStart?")

mouse.KeyDown:connect(function(key)
    if key:lower() == "f" then
        createNPC:FireServer()
        --createPartEvent:FireServer()
        --print("Test1")
        --particlesEvent:FireServer()
    end
end)

Yes, I do realize "mouse.KeyDown" is depreciated and I should be using "UserInputService"

script

local storedNPC = game.ReplicatedFirst["NPC"]
local replicatedStorage = game.ReplicatedStorage
local createNPC = Instance.new("RemoteEvent", replicatedStorage)
createNPC.Name = "NPC"

local function SummonNPC(player)
    print(player.Name, "is summoning a MEGA NOOB")
    local cloneNPC = storedNPC:Clone()
    cloneNPC.Parent = game.Workspace
--[[    local RightLeg = Instance.new("Part", cloneNPC)
    RightLeg.Name = "Right Leg"
    RightLeg.CFrame = cloneNPC["Right Arm"].CFrame*CFrame.new(3.81,7.484,0)
    RightLeg.Size = Vector3.new(3.402, 8.164, 5.443)
    RightLeg.CanCollide = false   --]]
--[[ In the comment above I tried scripting in a new right leg
    where the right leg is suppose to be on a NPC --]]
    for i, v in pairs(storedNPC:GetChildren()) do
        if v.ClassName == "Part" then
            v.CFrame = player.Character.Torso.CFrame*CFrame.new(0,3,3)

        end
    end
end

createNPC.OnServerEvent:connect(SummonNPC)

For this next code below...I was wondering if this part of the script(located inside of the NPC) could be affecting it? I'm asking this since I have no clue why that many numbers are needed inside of "CFrame.new()"

local RightHip = Instance.new("Motor")
local Figure = script.Parent 
--"script.Parent" goes to the model named "**MEGA NOOB**" which is 
--located in Workspace
RightHip.Part0 = Torso
    RightHip.Part1 = Figure["Right Leg"]
    RightHip.MaxVelocity = 0.1
    RightHip.Name = "Right Hip"
    RightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
    RightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)

I've tried going on roblox lua wiki looking up these 2 main things: "How to rotate parts" & "Understanding joints". I've went on devforum to see if this issue was affecting anyone else....No luck there. I've even went on google and looked up "roblox lua How do I create an NPC" and I didn't find any luck there either.

My Question is: Why is this happening and how do I fix it?

Bonus: It would also help if someone could please explain what the why the amount of numbers in the last bit of code in the "CFrame.new()". You don't have to answer this and if you don't, no worries. I'm mostly concerned with the main issue at hand. Just saying I would like to understand that if possible.

0
Does your npc have a humanoidrootpart? firestarroblox123 440 — 5y
0
No but all the limbs are welded to the torso so they shouldn't be acting like that. How would I go upon making one? awesomeestef1 -3 — 5y

Answer this question