Why isn't My Grab System Working?

why isn;t it work

explorer

image

client

--//// Varibles


--// Config

local DragForce = 300


--// Important

local Player = game.Players.LocalPlayer


--// Services

local RunService = game:GetService("RunService")


--// Other

local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera

local Dragging = false
local CurrentObject = nil
local CurrentMover = nil


--//// Script


--// Functions


--// Script



Mouse.Button1Down:Connect(function()
	local Target = Mouse.Target
	if Target then
		if Target.Anchored == false then
			local mvr = Instance.new("BodyPosition")
			CurrentObject = Target
			
			CurrentMover = mvr
			--CurrentMover.P = DragForce
			CurrentMover.D = 100
			CurrentMover.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			CurrentMover.Parent = CurrentObject
			
			script.RemoteEvent:FireServer("SetNetwork",CurrentObject)
		end
	end
end)

Mouse.Button1Up:Connect(function()
	if CurrentObject and CurrentMover then
		CurrentObject:FindFirstChildWhichIsA("BodyPosition"):Destroy()
		CurrentObject = nil
	end
end)

RunService.RenderStepped:Connect(function()
	if CurrentObject and CurrentMover then
		local Goal = Camera.CFrame.Position+(Camera.CFrame.LookVector-Mouse.Hit.Position).Unit*15
		--CurrentBodyMover.Force = Goal
		CurrentMover.Position = Goal
		
		print(tostring(Goal))
	end
end)



servor

script.Parent.OnServerEvent:Connect(function(Player,Act,Obj)
	if Act == "SetNetwork" then
		Obj:SetNetworkOwner(Player)
	end
end)
1 Like

oh in terms of not working it literally just doesn’t work, although it does detect the object

so its not aplieing velocity or am i doing it wrong

1 Like

I would recommend using AlignPosition I used it in remaking my Drag system recently before I used BodyPosition like you.BodyPosition is deprecated but It should be working

1 Like

how do i use alignposition for my drag system

1 Like

I created a Cursor that followed the mouse at all times. and Then I create Two attachments one I place in my cursor and then another into the part where i also put the AlignPosition Constraint. Its a lot of code because it was tinkered a lot
DraggingGif

It would be easier to show you my old code using body movers

can you show me the old code with body movers and I can see how you did it and try to do what you did

1 Like

I am deleting lines here and there but here’s some examples

ClientSide Pickup Example
local Mouse = Player:GetMouse()
		local Mass = Object:GetMass() local MForce = Vector3.new(math.huge,math.huge,math.huge)--50000,50000,50000)
		local BP = Instance.new("BodyPosition") BP.Parent = Object BP.Name  = 'Telekinesis'
			BP.Position = Mouse.Hit.Position BP.P = 450	BP.D = 50
			BP.MaxForce = MForce
		local BAV = Instance.new("BodyAngularVelocity")
		BAV.Name = "AngleStabilizer"
		BAV.AngularVelocity = Vector3.new(0,0,0)
		BAV.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
		BAV.P = 250
		BAV.Parent = Object

Serverside PickUp
local Holding = workspace.MouseTargetFilterStorage.Players.Players_Telekinesis[Player.Name].Holding
	local HoldingChildren = Holding:GetChildren()
	if #HoldingChildren == 0 then
		if Object.ClassName == "Model" then
					
			local ObjectWithin = Object.PrimaryPart

				Object.Parent = Holding
			print('Test2')			
				ObjectWithin:SetNetworkOwner(Player)
		else
				Object:SetNetworkOwner(Player)

				Object.Parent = Holding
			print('Test1')
		end		
	end	
ServerSide Dropping
TelekinesisModule.CleanObject(Player,Object,SecObj)

	local Holding = workspace.MouseTargetFilterStorage.Players.Players_Telekinesis[Player.Name].Holding
	local HoldingChildren = Holding:GetChildren()

	if #HoldingChildren ~= 0 then
		if Object and Object:IsA('Model') then
			local ObjectWithin = Object.PrimaryPart
			Object.Parent = workspace.Interactable
			ObjectWithin:SetNetworkOwner(nil)
		else
			Object.Parent = workspace.Interactable
			Object:SetNetworkOwner(nil)
		end
	end
Moving Part Around
RunService.RenderStepped:connect(function()
		if Object:FindFirstChild('Telekinesis') then
			local TelePos = Character.Head.Position + (Mouse.Hit.p - Character.Head.Position).unit* Distance
				Object.Telekinesis.Position = position
		end
end
end)

but yea here’s roughly the system not it entirely but maybe it could help :person_shrugging: ask me any questions you may have

i mostly needed the client script

i tried to set the position to the mosue hit position, and it just didn’t work

i have a feeling that theres not something wrong with my script and the game itsself, i could give you the place file if you want so you can check the script better or something

Its okay we probably could get it working just from a few messages. Just to double check no errors right? have you tried picking up something and checking explorer to see if the body movers were added.

I would remove the button-Up** function or at least comment it out right now and click a part and then open explorer and click on the body mover and edit its properties live as you test

I have added print statments to the runservice and it prints the goal, the body movers also get added, to the part, so I dont know why its not working

I think you just need to mess around in playtesting to see what the issue could be like clicking on the part looking at the bodymover live. Have you tried?

i have, i have even tried changing the properties of the bodymover, but it still just refuses to work

Did you comment on this first before testing?Were you able to see it updating the position

The position run service function prints?

im confused on what you mean cgharac

Wanted you to remove it by commenting it out

-- commenting

so that you can edit the bodymovers properties and find out what was wrong rereading and I noticed what was different from your code and my example you never set the Pressure (p) Property so there’s no force moving the body mover.

I forget to mention in the new code i set the P to 450 and it still didnt work and i did inspect the things

Inspect how the mouse Up function is still active. :thinking: how would you view the properties of Body position when it deletes after you lift mouse button

well i used a bug that you hold mouse button then open ESC then the mouse button is still active

That works but before you never answered when I asked if this.

is printing and you have no errors right

Yes, no errors are erroring anywhere, its odd that its not working