I want to make a part that spreads when you touch it, but it wouldnt work. What I have so far :
function onTouch(hit) script.Parent.CFrame.Vector3(5,1,6) wait(10) end
Size
is just a regular property of Parts, just like Transparency
or BrickColor
.
When we set Transparency
, it looks like this:
script.Parent.Transparency = 0.5
So when we change Size
, it should look the same:
script.Parent.Size = ...
However, a Size
isn't a number like Transparency
is. It's a Vector3
To make a new Vector3 value we use the constructor Vector3.new(x,y,z)
We can also operator on Vector3s in a way very similar to numbers to produce new ones. Just like we can use Transparency + 0.1
, we can also add to Vector3s:
script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1) -- Increases the X, Y, and Z components by 1 stud
If you're doing this with a Touched
event, you'll probably want to add some sort of debounce system to prevent problems from the part repeatedly getting touched because it's getting larger:
wasTouchedLastSecond = false function onTouch() if not wasTouchedLastSecond then wasTouchedLastSecond = true script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1) wait(1) wasTouchedLastSecond = false end end