Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
LostPast 253 Moderation Voter
11 years ago

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

Log in to vote
1
Answered by 11 years ago

Can't you just use the Water Terrain?

01--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
02 
03while true do
04    wait()
05    script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,1,0) --You forgot to add 'script'
06    wait()
07    script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-1,0)
08end
09 
10--With CFrames, you should do an asterisk.
Ad
Log in to vote
1
Answered by
m0rgoth 75
11 years ago

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:

01while wait() do
02    for i = 1,10 do
03        script.Parent.CFrame = script.Parent.CFrame + CFrame.new(0,1,0)
04        --I would also reccomend using the '*' operator rather than the '+' for CFrame manipulation.
05            --This makes the part move along its local space, rather than the world's.
06        --script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,1,0)
07    end
08    for i = 1,10 do
09        script.Parent.CFrame = script.Parent.CFrame - CFrame.new(0,1,0)
10        --script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-1,0)
11    end
12end

Answer this question