I’m attempting to make a grab player feature but it flings the player into the ground. I tried making the player being grabbed sat constantly, but that just made it worse.
Server script:
game.ReplicatedStorage.Remotes.Grab.OnServerEvent:Connect(function(p,char)
if not p.Character.Head:FindFirstChild("GrabWeld") then
for i, v in pairs(game.Players:GetPlayers()) do
print((v.Character:GetPrimaryPartCFrame().Position - p.Character:GetPrimaryPartCFrame().Position).magnitude)
if v.Character and v ~= p and v.Character:FindFirstChild("Ragdolled") then
if (v.Character:GetPrimaryPartCFrame().Position - p.Character:GetPrimaryPartCFrame().Position).magnitude <= 5 then
local part = v.Character.PrimaryPart
spawn(function()
local Grabbed = false
if not part.Parent:FindFirstChild("Grabbed") then
local e = Instance.new("StringValue")
e.Name = "Grabbed"
e.Parent = part.Parent
else
Grabbed = true
end
if Grabbed == false then
local Weld = Instance.new("Weld")
Weld.Parent = p.Character.Head
Weld.Part0 = part.Parent.UpperTorso
Weld.Name = "GrabWeld"
Weld.Part1 = p.Character.Head
for i, v in pairs(part.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Massless = true
end
end
spawn(function()
repeat
part.Parent.Humanoid.Sit = true
until not p.Character.Head:FindFirstChild("GrabWeld")
end)
part.Parent.Humanoid.JumpPower = 0
part.Parent.Humanoid.WalkSpeed = 0
wait(.5)
p.Character:SetPrimaryPartCFrame(p.Character.PrimaryPart.CFrame.Position*Vector3.new(0,5,0))
end
end)
end
end
end
else
p.Character.Head.GrabWeld.Part0.Parent.Grabbed:Destroy()
p.Character.Head.GrabWeld:Destroy()
end
end)
Any help would be appreciated.