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

Moving water... Isn't working...?

while wait() do for i=1,10 do Parent.CFrame = CFrame + CFrame.new(0,1,0) end for i=1,10 do Parent.CFrame = CFrame - CFrame.new(0,1,0) end end

Didn't give an error, but it isn't moving the water up and down.

2 answers

Can't you just use the Water Terrain?

--You probably shouldn't do a for loop, otherwise even if it's in a while loop it won't go on forever. Unless it's a huge number

while true do 
	wait()
	script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,1,0) --You forgot to add 'script'
	wait()
	script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-1,0) 
end

--With CFrames, you should do an asterisk.

Parent is not a global variable of scripts. You need to use the 'script' variable. Also, you have a random 'CFrame' in the calculation which should have some sort of reference:

while wait() do
	for i = 1,10 do
		script.Parent.CFrame = script.Parent.CFrame + CFrame.new(0,1,0)
		--I would also reccomend using the '*' operator rather than the '+' for CFrame manipulation.
			--This makes the part move along its local space, rather than the world's.
		--script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,1,0)
	end
	for i = 1,10 do
		script.Parent.CFrame = script.Parent.CFrame - CFrame.new(0,1,0)
		--script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-1,0)
	end
end

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