Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can you help me fix this glitch?

function grow()
	local mesh = script.Parent.Mesh
		wait(20)
	mesh.Scale = Vector3.new(1.8, 1.5, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 2, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 2.5, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 3, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 3.5, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 4, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 4.5, 2)
		wait(20)
	mesh.Scale = Vector3.new(1.8, 5, 2)
end

script.Parent.Mesh.Changed:connect(grow)

The problem is... whenever the mesh grows, the script starts over because of the change. This causes an unwanted error. Where it's occurring: http://www.roblox.com/games/357002407/Grass-Simulator

1 answer

Not exactly sure what your problem is, however there is an easier way to write this down. Try using a For loop instead, like this:

function grow()
local mesh = script.Parent.Mesh
for i = 1,8 do
mesh.Scale = mesh.Scale + Vector3.new(0, 0.5, 0)
wait(20)
end

What this does is it creates a loop that happens 8 times, and each time it loops it adds 0.5 on y axis of the mesh's scale.

2 comments

0

the problem is that it cant use a changed loop because when it grows, it is classified as changed. therefore it repeats over and over

0

Well, you could try removing the changed event, and just making it have a wait(1) before it starts in a serverscript. Other than that I don't really know how to help.

This discussion is preserved as it was. New answers, comments, and votes are closed.