Recently, I’ve made a pickup system, but I’ve noticed that weird glitches have been going on such as the picked up player walking as well as my character being tilt a bit as if there was weight to the other character.
Here’s my code:
--// Settings
local function PickupPlayer(Player, Target)
local Character = Player.Character
local Root = Character.HumanoidRootPart
local TargetRoot = Target.HumanoidRootPart
TargetRoot.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(1.5,1.5,0) * CFrame.Angles(math.rad(20),0,0)
for _, v in pairs(Target:GetChildren()) do
if v:IsA("BasePart") then
v.Massless = true
end
end
PHYSICS.setCollisionGroup(Target, "Uncollide")
local Weld = Instance.new("WeldConstraint")
Weld.Name = "Carry"
Weld.Part0 = Root
Weld.Part1 = TargetRoot
Weld.Parent = Root
end
local function DropPickedup(Player)
local Character = Player.Character
if Character.HumanoidRootPart:FindFirstChild("Carry") then
local Target = Character.HumanoidRootPart.Carry.Part1.Parent
PHYSICS.setCollisionGroup(Target, "Humanoid")
for _, v in pairs(Target:GetChildren()) do
if v:IsA("BasePart") then
v.Massless = false
end
end
Players:GetPlayerFromCharacter(Target).States.Pickedup.Value = false
Character.HumanoidRootPart.Carry:Destroy()
end
end
Here’s what it looks visually:
https://gyazo.com/e2f08df441b1b7e979110ed970bac277
https://gyazo.com/1e8a1a9f99a39ac84c0797686195b3e8
It seems like the entire character is lighter (maybe because I’ve set the target to massless). I believe the issue may be regarding the root part because of me using a weld constraint but I’m not sure.