How to make tree be laying down in players arms

Hey there, So I have this system where the player can pick up a tree, but after it does so the tree is in an awkward position and i’m wondering what I need to do to have it lying down in the players arms.

local trees = game.Workspace.Trees
local touched = false

for i, tree in pairs(trees:GetChildren()) do
	
	tree.Touched:Connect(function(hit)
		
		if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= "Worker" and touched == false and tree.Parent == trees then
			
			touched = true
			
			local player = hit.Parent
			local hum = player:FindFirstChild("Humanoid")
			
			--hum.WalkSpeed = hum.WalkSpeed - 10
			
			warn(player.Name)
			
			tree.Parent = player
			tree.Color = Color3.new(0.792157, 0.792157, 0.792157)
			tree.Anchored = false
			tree.CanCollide = false

			local vec = Vector3.new(player["HumanoidRootPart"].Position.X, player["HumanoidRootPart"].Position.Y, player["HumanoidRootPart"].Position.Z)

				tree.CFrame = CFrame.new(player.HumanoidRootPart.Position + Vector3.new(0, 2, 0))
				tree.Orientation = Vector3.new(player.HumanoidRootPart.Orientation + Vector3.new(20, -10, 0))

				local weld = Instance.new("WeldConstraint")
				weld.Name = "TreeWeld"
				weld.Part0 = tree
				weld.Part1 = player:FindFirstChild("RightUpperArm")
	
				weld.Parent = player

		else
			
		end
		
	end)
	
end

Screenshot 2024-08-05 153727

adjust the weld offset or adjust the pivot point of the tree.
i would look at a tutorial or another forum post as i cant remember how to off the top of my head how to do that, but it should work

1 Like

I would use a Motor6D if you want to move around with the tree and adjust the offsets, but with a dummy rig. Part0 and c0 being the HumanoidRootPart, and Part1 and c1 being the tree’s PrimaryPart. When you have the Motor to your liking, you can just clone/disable and re-enable it and use it as a reference in your code to attach to the player.

1 Like

Ive tried it and its very difficult tying to figure out the angles and stuff

Ill look into this and lyk how it goes, thanks!

i would go with IdistinctDev’s solution, it also give you the ability to create animations as well

1 Like

So I have the Motor6D and im wondering how I change it inside of the script, this doesnt work…

	local weld = Instance.new("Motor6D")

	weld.Name = "TreeWeld"
	weld.Part0 = tree
	weld.Part1 = player:FindFirstChild("RightUpperArm")
	weld.Parent = player

	weld.C0.Position = Vector3.new(0, 1.4, 0)
	weld.C0.Rotation = Vector3.new(6, 0, 80)

Error says “Position cannot be assigned to”

Bit of a more out of the box idea. Have you tried making the tree a tool rather than a child of the player?

You can adjust a tool’s grip with a plugin - all you need is a part inside the tree called ‘Handle’ and you could tweak the script to just pick-up the tree as a tool instead.

1 Like

this is because the “c’s” are a CFrame, so you have to set it as a CFrame, sorry for not being clear on this earlier.

weld.C0 = CFrame.new(Vector3.new(0, 1.4, 0), Vector3.new(6, 0, 80))
1 Like

I did try this, but i really didnt want the player to be able to put the tree away whenever they wanted :joy:

Thank you for the help, i ended up keeping the weld constraint and this worked.

			local offset = CFrame.new(0, 0, -1)
			local rotation = CFrame.Angles(0, 0, math.rad(90))
			tree.CFrame = player.HumanoidRootPart.CFrame * offset * rotation

			local weld = Instance.new("WeldConstraint")
			weld.Name = "TreeWeld"
			weld.Part0 = tree
			weld.Part1 = player.HumanoidRootPart
			weld.Parent = tree
1 Like

Glad to see you found your fix. Good luck with your project!

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