I want to change the part when it’s going In the machine to a model from replicated storage into the game but how do I do that?
this is my script
local tycoon = script.Parent.Parent.Parent
local processor = script.Parent.Processor
local objectsFolder = tycoon.Objects
local Glass = game.ReplicatedStorage.Glass
local Bottle = game.ReplicatedStorage.Bottle
local function processPart(part)
if part.Name == “CleanGlass” then
part.Name = “GlassBottle”
part.Material = Enum.Material.SmoothPlastic
end
end
local function onTouched(otherPart)
if otherPart.Parent == objectsFolder then
processPart(otherPart)
end
end
local tycoon = script.Parent.Parent.Parent
local processor = script.Parent.Processor
local objectsFolder = tycoon.Objects
local Glass = game.ReplicatedStorage.Glass
local Bottle = game.ReplicatedStorage.Bottle
local function processPart(part)
if part.Name == “CleanGlass” then
part.Name = “GlassBottle”
part.Material = Enum.Material.SmoothPlastic
end
end
local function onTouched(otherPart)
if otherPart.Parent == objectsFolder then
processPart(otherPart)
end
end
processor.Touched:Connect(onTouched)
^ Code block please. I will edit this reply once I read through the code.
local function processPart(part)
if part.Name == "CleanGlass" then
local GlassBottle = Glass:Clone()
GlassBottle.Name = "GlassBottle"
GlassBottle.Position = part.Position
GlassBottle.Parent = workspace
end
end
Something like this may work, however I am not sure about the position part, you may need to use CFrames.
I just made it a code block so that others can read it, I have added a following edit that may work. To code block please use ```lua at the start and at the end ```
i have a part called proccesor part in the cutting machine when the part goes in the object it should change into the bottle model in replicated storage