This is a script that gets cloned into a MeshPart. I'm trying to make it so the MeshPart grows until a certain size. Error: Workspace.taunter165.LowerTorso.cloud.Script2:5: attempt to compare two userdata values
23:36:53.648 - Stack Begin
23:36:53.651 - Script 'Workspace.taunter165.LowerTorso.cloud.Script2', Line 5
23:36:53.653 - Stack End
if script.Parent.Name == "cloud" then wait(0.1) local p = script.Parent repeat p.Size = Vector3.new(11*1.18,5*1.18,7*1.18) until p.Size > Vector3.new(22, 10, 14) wait(0.2) p.Parent:Destroy() end
The reason your code errors is because you need to compare the individual x/y/z axis members of the Vectors.
Secondly, your code would yield indefinitely if it didn't error because 11*1.18
will always be 11*1.18
and so on; therefore, p.Size
will never be greater than the target. And you didn't call the wait
function.
You need to implement a step
variable. A variable that increments each iteration:
local p = script.Parent local speed = 1.18 if p.Name == "cloud" then wait(0.1) local step = 1 repeat wait() local offset = step * speed p.Size = Vector3.new(11 * offset,5 * offset,7 * offset) until p.Size.X > 22 or p.Size.Y > 10 or p.Size.Z > 14 wait(0.2) p.Parent:Destroy() end
By preference, I would do this using a numerical for loop. Its syntax makes you declare a step variable initially, and the bounds are easy to correspond to numbers:
local p = script.Parent local speed = 1.18 if p.Name == "cloud" then wait(0.1) local origin = p.Size for step = 1,10 do --start,finish(numbers may be inaccurate) local offset = step * speed p.Size = origin + Vector3.new(offset,offset,offset) wait() end wait(0.2) p.Parent:Destroy() end