#Introduction
When creating a tree, I implemented a system where the tree will randomize its position every time it is chopped down. However, the tree is a model and I tried using :GetChildren() to solve it, but it didn't work.
#Script
Here's my script:
local player = game.Players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
while not character.Parent do
character.AncestryChanged:Wait()
end
local Humanoid = character:WaitForChild('Humanoid')
local HRP = character:WaitForChild('HumanoidRootPart')
local mouse = player:GetMouse()
local Anim = Instance.new("Animation",script.Parent)
Anim.Name = "ChopAnim"
Anim.AnimationId = 'rbxassetid://3027147369'
local Animation = Humanoid:LoadAnimation(Anim)
local Part = script.Parent
local currentChops = script.Parent.CurrentChops
local maxChops = script.Parent.RequiredChops
game.ReplicatedStorage.PressedE.OnServerEvent:Connect(function()
if (HRP.Position - Part.Position).magnitude < 6 then
if player.PlayerGui.Job.Value == "Lumberjack" then
print("is job")
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
Animation:Play()
script.Parent.ChopSFX:Play()
for i = 0,10,1 do
currentChops.Value = i
wait(script.Parent.ChopSFX.TimeLength)
end
currentChops.Value = 0
script.Parent.BillboardGui.Enabled = false
script.Parent.ProgressOfInter.Enabled = false
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
Animation:Stop()
script.Parent.ChopSFX:Stop()
script.Parent.FallTree:Play()
for i = 0,1,.1 do
script.Parent.Transparency = i
script.Parent.Parent.Branch.Transparency = i
script.Parent.Parent.Branch1.Transparency = i
wait()
end
script.Parent.Name = "Cooldown"
local LogClone = game.ReplicatedStorage.Log:Clone()
LogClone.Parent = player:WaitForChild('Backpack')
game.ReplicatedStorage.TreeCut:FireClient(player)
script.Parent.Position = Vector3.new(math.random(-100,100),script.Parent.Position.Y,math.random(-100,100));
wait(script.Parent.FallTree.TimeLength)
for i = 1,0,-.1 do
script.Parent.Transparency = i
script.Parent.Parent.Branch.Transparency = i
script.Parent.Parent.Branch1.Transparency = i
wait()
end
script.Parent.Name = "Tree"
script.Parent.BillboardGui.Enabled = true
script.Parent.ProgressOfInter.Enabled = true
else
game.ReplicatedStorage.NotJob:FireClient(player)
print("does not have job of lumberjack")
end
end
end)
#Conclusion
Sorry if it's a little hard to read...
I have no idea how I would make the branches go randomize WITH the tree, not randomize independently. I tried using WeldConstraints, but it didn't work.
Any help please? I've tried all the methods I know.
Sincerely, Sensei_Developer
EDIT: Apparently, you can actually use Unions to help with this type of situation. It solved my question, so yay!

12 comments
Did you try MoveTo and SetPrimaryPartCFrame?
If those ^^ don't work (for some reason) you can get the relative position of the branches with the tree and move them to the same point with the increment
model:MoveTo(Position) | model.PrimaryPart = PART; model:SetPrimaryPartCFrame(CFrame) (Note that moveto works as setting a position to a vector3 which may cause the end result to become innacurate (jumping ontop of things, you can use primarypart to prevent this))
Uh, okay. I'll try :MoveTo())
I tried :SetPrimaryPartCFrame(), but it didn't wor.
work*
Nope. Doesn't work.
@RedcommanderV2 What do you mean? Show me examples in answers, please.
What didn't work exactly? (any errors?). And to clarify, you have a main part and other parts and you want the other parts to move relatively to the main part (so the model looks the same as it did before the reposition)
Actually, I just solved it lol. I just used unions.
Oh nice, (tho don't forget that unions can only use 1 material so if your build used multiple you might have some problems)
Okay. I know that.