Grabbing system causes player to fly

Source (local)
local lplr = game.Players.LocalPlayer
local mouse = lplr:GetMouse()

local cc = workspace.CurrentCamera
local sM : Enum.Material 

local m = 3


local disval = Instance.new('NumberValue')
local cnt : RBXScriptConnection
local auth = game.ReplicatedStorage.AuthorizeNodeControl

local cnode
local bMouse = lplr.PlayerGui:WaitForChild('extra').bMouse
local savedo = Vector3.new(0,0,0)
local tatt = Instance.new('Attachment') tatt.Parent = workspace.Baseplate tatt.Name = 'tatt'

mouse.WheelForward:Connect(function()
	if cnode then
		if m < 5.8 then
			m+= .2
		end
	end
end)
mouse.WheelBackward:Connect(function()
	if cnode then 
		if m > .8 then
			m-= .2
		end
	end
end)

mouse.Move:Connect(function()
	if not cnode and mouse.Target then
		if mouse.Target.Parent == workspace.nodes then
			if mouse.Target.OwnerId.Value == lplr.UserId then
				bMouse.Visible = true
				bMouse.Position = UDim2.fromOffset(mouse.X,mouse.Y)
				return
			end
		end
	end
	bMouse.Visible = false
end)
local correct = function()
	local targetvec = mouse.Origin + mouse.Origin.LookVector*m
	local curvec = cnode.CFrame
	local dis = (curvec.Position-targetvec.Position).Magnitude
	local angle = CFrame.lookAt(curvec.Position,targetvec.Position)
	local line = workspace:FindFirstChild('line') or Instance.new('Part')
	local cpos = lplr.Character:WaitForChild('RightHand').CFrame
	line.Name = 'line' 
	line.CanCollide = false line.Anchored = true line.Size = Vector3.new(.1,.1,(cpos.Position-curvec.Position).Magnitude)
	line.Transparency = .6
	line.CFrame = 
		CFrame.lookAt(
			curvec.Position,cpos.Position) + 
		(
		CFrame.lookAt(curvec.Position,cpos.Position).LookVector *
		(cpos.Position-curvec.Position).Magnitude)/2
	line.Parent = workspace
	local sval = angle.LookVector*dis*m
	if dis < .1 then sval = Vector3.new(0,0,0) end
	cnode.Attachment.LinearVelocity.VectorVelocity = sval

end

mouse.Button1Down:Connect(function()
	local tnode = mouse.Target
	if tnode then
		if tnode.Parent == workspace.nodes then
			if auth:InvokeServer(tnode) then
				tatt.Orientation = tnode.Orientation
				local newt = Instance.new('AlignOrientation')
				newt.Parent = tnode newt.Name = 'newt'
				newt.Enabled = true newt.Attachment0 = tnode.Attachment newt.Attachment1 = tatt
				tnode.Transparency = .5
				sM = tnode.Material
				tnode.Material = Enum.Material.Neon
				tnode.Attachment.LinearVelocity.Enabled = true
				cnt = game["Run Service"].RenderStepped:Connect(correct)
				cnode = tnode
			end
		end
	end
end)


mouse.Button1Up:Connect(function()
	if cnode then
		-- Sets the client's view of the model back to regular.
		cnode.Transparency = 0
		cnode.Material = sM
		cnode.AssemblyAngularVelocity = Vector3.new(0,0,0)
		cnt:Disconnect()
		cnode.Attachment.LinearVelocity.VectorVelocity = Vector3.new(0,0,0)
		cnode.Attachment.LinearVelocity.Enabled = false
		cnode.newt:Destroy()
		if workspace:WaitForChild('line') then workspace:WaitForChild('line'):Destroy() end
		cnode = nil
	end
end)

what solutions are there to prevent this?

You could just set CanCollide on client so that you can’t collide,
or you could set CustomPhysicalProperties to PhysicalProperties.new(0,0,0,0,0) Although not so sure

What most games do to fix this is to detect touches and if it touches the player, it simply unequips:


function unequip()
     if cnode then
		-- Sets the client's view of the model back to regular.
		cnode.Transparency = 0
		cnode.Material = sM
		cnode.AssemblyAngularVelocity = Vector3.new(0,0,0)
		cnt:Disconnect()
		cnode.Attachment.LinearVelocity.VectorVelocity = Vector3.new(0,0,0)
		cnode.Attachment.LinearVelocity.Enabled = false
		cnode.newt:Destroy()
		if workspace:WaitForChild('line') then workspace:WaitForChild('line'):Destroy() end
		cnode = nil
	end 
end

mouse.Button1Down:Connect(function()
	local tnode = mouse.Target
	if tnode then
		if tnode.Parent == workspace.nodes then
			if auth:InvokeServer(tnode) then
				tatt.Orientation = tnode.Orientation
				local newt = Instance.new('AlignOrientation')
				newt.Parent = tnode newt.Name = 'newt'
				newt.Enabled = true newt.Attachment0 = tnode.Attachment newt.Attachment1 = tatt
				tnode.Transparency = .5
				sM = tnode.Material
				tnode.Material = Enum.Material.Neon
				tnode.Attachment.LinearVelocity.Enabled = true
				cnt = game["Run Service"].RenderStepped:Connect(correct)
				cnode = tnode

                              tnode.Touched:Connect(function(touched)
                                     local player = game.Players:GetPlayerFromCharacter(touched:FindFirstAncestorWhichIsA("Model"))
                                     If player then
                                          unequip()
                                    end
                              end)
			end
		end
	end
end)


mouse.Button1Up:Connect(unequip)

Sorry for the bad formatting im on mobile

Make sure when you pick up an item the item has CanCollide marked off.

Collision groups aren’t client-sided as far as I remember and if I disable collisions then the object will go through parts

Have you used a touched event, something like,

Mouse.Target.Touched:Connect(function(Action)

if Action:FindFirstChild(“Humanoid”) then

Mouse.Target.CanCollide = false

end

end)

Mouse.Target.TouchEnded:Connect(function(Action)

if Action:FindFirstChild(“Humanoid”) then

Mouse.Target.CanCollide = true

end

end)

Still, CanCollide for other parts is client-sided.

Yes, but the object your holder wont go through other parts it will only go though you

Did you try this solution @coolalex1835

No I just added a collision group between entities and characters.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.