You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to achieve a character carrying system so that characters can carry other characters including NPCs.
- What is the issue? Include screenshots / videos if possible!
The system is very choppy when the character doing the carrying goes into shift lock switch. The current system I have works essentially perfectly except for when the character doing the carrying is in shift lock switch. This issue also occurs in first person.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using AlignPosition and AlignOrientation, but I had the same issue. I also used a Weld, WeldConstraint and RigidConstraint, but I had the issue of both characters dying when one character died. I also tried using .Stepped and .Heartbeat as well as a while task.wait() loop.
In the video below, the attachment is visible. I am setting the HumanoidRootPart CFrame of the character being carried to the attachment’s WorldCFrame, but as you can see in the video, there’s a weird delay when in shift lock (also in first person).
-- This is in a LocalScript responding to an OnServerEvent
if Request == "CarryCharacter" then
local CarryTarget = Data.CarryTarget
local Attachment1 = Data.Attachment1
if CarryConnections[CarryTarget] ~= nil then
CarryConnections[CarryTarget]:Disconnect()
CarryConnections[CarryTarget] = nil
end
local TargetHumanoidRootPart = CarryTarget.HumanoidRootPart
local SmoothInfo = TweenInfo.new(Data.SmoothTime or 0, Data.EasingStyle or Enum.EasingStyle.Sine, Data.EasingDirection or Enum.EasingDirection.Out)
CarryConnections[CarryTarget] = RenderStepped:Connect(function()
local S, E = pcall(function()
TweenService:Create(TargetHumanoidRootPart, SmoothInfo, {CFrame = Attachment1.WorldCFrame}):Play()
end)
if not S then
warn("Carry replication broken due to an error:", E)
CarryConnections[CarryTarget]:Disconnect()
CarryConnections[CarryTarget] = nil
end
end)
end
if Request == "EndCharacterCarry" then
local CarryTarget = Data.Character
if CarryConnections[CarryTarget] ~= nil then
CarryConnections[CarryTarget]:Disconnect()
CarryConnections[CarryTarget] = nil
for _, Part in pairs(CarryTarget:GetDescendants()) do
if Part:IsA("BasePart") then
Part.Massless = false
Part.CanCollide = true
end
end
end
end