BodyPosition doesn't work right away

Hello!

Edit: I have looked through the forums for solutions to the problem as there are topics that were created, but none have been answered :frowning:

I’m trying to create a Lumber Tycoon 2-esq grabbing system - As in you click on a part to drag it around within 10 studs of your character in the air, and releasing will let the part fall - It generally works pretty well, except for one hiccup at the start.

You see, BodyPosition will bug out towards the beginning and not work at all, only after 2-3 tries does it work as I hoped it would. Here’s my relevant script:

Another function provides the part the player clicks on to the this function

local function bodyMovers (part)
	local bodyPos = Instance.new("BodyPosition")
	bodyPos.MaxForce = Vector3.new(400000,400000,400000)
	bodyPos.Parent = part
	bodyPos.Position = part.Position
	bodyPos.P = 100000
	bodyPos.D = 1000
	bodyPos.Name = "BodyPos"
	
	return bodyPos
end

In the below script, “obj” is the same as “part” in the other script

local function mouseMoved ()
	if dragging then
		local cf = CFrame.new(char.Head.Position, mouse.Hit.Position)
		obj.BodyPos.Position = (cf + (cf.LookVector * 10)).Position
	end
	wait()
end

Those are all the functions that deal with body position, any ideas as to what the problem could be?

Remember to give network ownership of the part to the player.

Also have you seen this well done community tutorial?

2 Likes

That is a great tutorial, Thank you for linking me, I’ll be sure to implement it into my own system!

1 Like