If you would like to keep the original position Y and Z position of your part, you have to references it by doing this
part.Position.Y
part.Position.Z
Also, based on your script, it looks like you would want a part to keep respawning over and over again, there seems to be a minor mistake.
In order to create a part over and over again, you must put the part variable inside the function so it is called multiple times.
Second, I would recommend putting a wait() on your while loop because if you won't, it is going to crash.
function spawnPart(posX)
local part = Instance.new("Part")
part.Position = Vector3.new(posX,part.Position.Y, part.Position.Z )
part.Parent = workspace
end
while true do
spawnPart(10)
wait()
end
In your script, it seems like you only want the part's X axis to be customizable with a parameter, so you should enter a value for it, it can be any number value.
1 comment
Thank you!