Carrying a player/NPC

So, in my game, I would like it so that a player can click on an NPC and carry them. I am unsure how to approach this. So far, I have tried, cloning the NPC and cloning a copy of the NPC out of ServerStorage (Without a script and click detector in) and welding it to the player’s HumanoidRootPart however this has made the player unable to turn unless in first person and then the player ‘slides’ along the ground and snaps back if you exit.

It is also incredibly easy to get stuck with it attached to you, I have tried to fix it by disabling CanCollide (It is easy to get stuck) on everything is to remove the Humanoid but then after a few seconds, the entire model disappears (I believe the weld breaks). I have also tried making the NPC massless = true however, this had no effect.

Current progress

To achive what I have done currently the server detects a players click and clones the NPC into the Character (game.Workspace) and localy welding and positioning it on the Character.

Server script inside the original NPC:

local function onClick(player)
	local sailor = game.ServerStorage.Missions.SailorRescue1.Sailor
	local sailorClone = sailor:Clone()
	sailorClone.Parent = game.Workspace:FindFirstChild(player.Name)
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)

Local script inside StarterGui - so PlayerGui ingame

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()

repeat
	wait()
until Character:FindFirstChild("HumanoidRootPart")

local sailor = Character:WaitForChild("Sailor")
sailor.HumanoidRootPart.Anchored = false
sailor.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame

 
local Weld = Instance.new("Weld", sailor.HumanoidRootPart)
Weld.Part0 = Character.HumanoidRootPart
Weld.Part1 = sailor.HumanoidRootPart
Weld.C1 = CFrame.new(0, -2, -1)
Weld.C0 = CFrame.new()

(I haven’t rotated it yet, it is meant to be a fireman’s lift)

Ideally, the player should click the NPC, the NPC appears to be given a firemans lift on the back of the player (locally or server side) without getting stuck and be able to walk around normally.

Any ideas are welcome.

1 Like

Does it have to be a humanoid? From the picture, it looks like the body you’re carrying could be replicated with parts. Then, you should be able to disable CanCollide and it should work.

Part of the problem is that the NPC is not network owned by the client. You are going to need to set the network ownership of said NPC’s parts to the client carrying it.

3 Likes

While that may work, I would later on like to add R6+15 characters.

How would I go about giving it network ownership?

https://developer.roblox.com/articles/Network-Ownership

1 Like

There is also the issue of both objects being characters. The one being carried might try something that will send both into space. In other words, using some kind of a force should keep the 2nd character in midair without affecting the 1st.

1 Like

Even after setting this nothing changes :confused:

I’ve been wrestling with this same issue for a while. I tried the exact same things as OP and the suggestions in this thread to no avail.

Would anyone be willing to help solve this?

The issues I face:

  • the NPC collides with walls/bricks
  • the NPC makes the player move weirdly
  • the NPC can get the player stuck in the walls and floor (surprisingly enough)
2 Likes

Have you tried setting Massless to true for all the NPC’s bodyparts?

Not the most experienced programmer but have you tried welding it to the upper/lower torso instead of the humanoidrootpart?

I also have this issue, looking for a solution on devforum and didn’t find it, so I did some tests and surprisingly it did solve the problem that has weird movement,
just set target humanoid.sit = true and set target.PrimaryPart:SetNetworkOwner(ply) will fix weird animation when moving