Part positioning messes up when I put them inside of a Tool

I am trying to make a burger cooking minigame in my game where you can stack different ingredients and then when you press a button it becomes a tool.

Currently however I have a problem with turning the burger into a tool where all the part’s positions mess up and combine together how would I make them keep their position in relation to each other?

Video of the issue:

Stacking Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LastItem = nil

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
	
	if hit.Parent:IsA("Tool") then
		if script.Parent.Parent:FindFirstChild(player.name) then
			local I = script.Parent.Parent:FindFirstChild(player.name) 
			
			local Ingredient = hit.Parent.Handle:Clone()
			Ingredient.Name = hit.Parent.Name


			Ingredient.Parent = LastItem
			Ingredient.Position = Vector3.new(LastItem.Position.X, LastItem.Position.Y + 0.35, LastItem.Position.Z)
			Ingredient.Anchored = true
			Ingredient.Orientation = Vector3.new(0,0,90)
			Ingredient.Transparency = 1
			
			local weld = Instance.new("Weld")
			weld.Parent = Ingredient
			weld.Part0 = Ingredient
			weld.Part1 = I
			
			game.ReplicatedStorage.HelpfulEvents.tEvent:FireClient(player, Ingredient)
			hit.Parent:Destroy()
			
			LastItem = Ingredient
		else
			
			local NameHaver = ReplicatedStorage.NameHaver:Clone()
			NameHaver.Parent = script.Parent.Parent
			NameHaver.Name = player.Name
			
			local I2 = script.Parent.Parent:FindFirstChild(player.name)
			
			local Ingredient = hit.Parent.Handle:Clone()
			Ingredient.Name = hit.Parent.Name
			
			
			Ingredient.Parent = I2
			Ingredient.CFrame = I2.CFrame
			Ingredient.Anchored = true
			Ingredient.Orientation = Vector3.new(0,0,90)
			Ingredient.Transparency = 1
			game.ReplicatedStorage.HelpfulEvents.tEvent:FireClient(player, Ingredient)
			
			local weld = Instance.new("Weld")
			weld.Parent = Ingredient
			weld.Part0 = Ingredient
			weld.Part1 = I2
			
			hit.Parent:Destroy()
			LastItem = Ingredient
			
		end
	end
	
end)

Button Script:

local detector = script.Parent.ClickDetector

detector.MouseClick:Connect(function(player)
	
	local Burgertool = Instance.new("Tool")
	local i = script.Parent.Parent:FindFirstChild(player.Name)
	local Burger = i
	
	Burger.Parent = Burgertool
	Burger.CFrame = script.Parent.CFrame
	
	Burger.Name = "Handle"
	
	Burger.Anchored = false	
	
	local Ingredients = Burger:GetDescendants()
		for i = 1, #Ingredients do
		
		if Ingredients[i]:IsA("Part") then
		Ingredients[i].Transparency = 0
			Ingredients[i].Anchored = false
		end
		
	end

	Burgertool.Parent = player.Backpack
	Burgertool.Name = "Burger"
	
	
	
end)
1 Like

Have you tried changing the Weld into a WeldConstraint ?

2 Likes

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