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
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
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.
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.