This is my duplication script.
local RS = game:GetService("ReplicatedStorage")
local doughValue = workspace.SergerStats.AmountODough
local doughTemplate = game.ServerStorage:WaitForChild("dough")
RS.Remotes.RequestDough.OnServerEvent:Connect(function(player)
if doughValue.Value <= 0 then
print("No Dough")
return
end
doughValue.Value -= 1
local clone = doughTemplate:Clone()
clone.Parent = workspace
clone:SetPrimaryPartCFrame(
game.Workspace.Blocker.CFrame * CFrame.new(0, 10, 0)
)
if clone:FindFirstChild("ServerOwner") then
clone.ServerOwner.Value = true
end
if clone.PrimaryPart then
clone.Dough.Anchored = false
clone.PrimaryPart:SetNetworkOwner(player)
clone.Name = "DoughYay"
end
end)
When it touches the Preparation Table
local prepTable = workspace:WaitForChild("PrepTable")
prepTable.Touched:Connect(function(hit)
local model = hit:FindFirstAncestorOfClass("Model")
if not model then return end
local state = model:FindFirstChild("State")
if not state or state.Value ~= "Dough" then return end
local pp = model.PrimaryPart
if not pp then return end
state.Value = "Flattened"
pp.Shape = Enum.PartType.Cylinder
pp.Size = Vector3.new(0.117, 2.8, 4.2)
pp.CFrame = CFrame.new(pp.Position) * CFrame.Angles(math.rad(90), 0, 0)
pp.Anchored = false
if not model:FindFirstChild("ToppingsPart") then
local topping = Instance.new("Part")
topping.Name = "ToppingsPart"
topping.Size = Vector3.new(0.001, 2.567, 4.2)
topping.Shape = Enum.PartType.Cylinder
topping.Anchored = false
topping.CanCollide = false
topping.TopSurface = Enum.SurfaceType.Smooth
topping.BottomSurface = Enum.SurfaceType.Smooth
topping.Parent = model
topping.Color = Color3.new(1, 0.8, 0.6)
topping.CFrame = pp.CFrame
topping.Position = topping.Position + Vector3.new(-.06, 0, 0) -- move it 8 studs up for visibility
local weld = Instance.new("WeldConstraint")
weld.Part0 = pp
weld.Part1 = topping
weld.Parent = pp
end
end)
When the Dough sits for some time, it just doesn’t want to include a TouchInterest to the ToppingsPart, which is needed in my Toppings script.