Hello, Scripting Helpers.
I am working on an SCP Project, and I'm currently trying to add a new item into the SCP-914 script. Basically what I'm trying to do is turn the item "Water Tank" into a "Hydrogen Tank," and clone the newly converted Hydrogen Tank. The first Hydrogen Tank gets converted without issue, but the second Hydrogen Tank gets completely broken. Is there any fix to this? Am I positioning it wrong? Any help would be greatly appreciated.
Code:
elseif item.Name == "Water Tank" then
item.Handle.BrickColor = BrickColor.new("Pastel green")
item.P1.BrickColor = BrickColor.new("Dark green")
item.P2.BrickColor = BrickColor.new("Dark green")
item.P3.BrickColor = BrickColor.new("Dark green")
item.P4.BrickColor = BrickColor.new("Dark green")
item.Name = "Hydrogen Tank"
item.Handle.Position = Vector3.new(-144, 85.5, 795)
local newitem = item:Clone()
newitem.Parent = game.Workspace
script.Disabled = true
Note: The tool is comprised of multiple parts.
The second Hydrogen Tank should spawn like this
But the second Hydrogen Tank spawns like this
I tried revising the code using an answer that SerpentineKing gave me, however, this happened.
SerpentineKing's code:
elseif item.Name == "Water Tank" then
item.Handle.BrickColor = BrickColor.new("Pastel green")
item.P1.BrickColor = BrickColor.new("Dark green")
item.P2.BrickColor = BrickColor.new("Dark green")
item.P3.BrickColor = BrickColor.new("Dark green")
item.P4.BrickColor = BrickColor.new("Dark green")
item.Name = "Hydrogen Tank"
item.Handle.Weld.C0 = CFrame.new(-144, 85.5, 795)
local newitem = item:Clone()
newitem.Parent = game.Workspace
script.Disabled = true

7 comments
Local script or server script?
Server script.
its because you change the handle's position, causing the welds associated with the handle to break
Well, is there anyway to move the entire tool over to the position where I want it to be, without breaking the welds?
The Weld C0 Property is not the position in the global field, but is instead the offset from the other part determined by the weld, so weld.C0 = CFrame.new(0, 0, 5) would be 5 studs away (z-axis) from the Weld's Part1 Instance
I think I get it now. I'll try again.
After rewriting and retrying the script multiple times, I fail to get a proper solution to the issue, as I keep getting the same result of the third picture. I will need more information on how to properly insert the line of code into the script. For now I will keep this question as unresolved.