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
10 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 10 years ago

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.
Ad
Log in to vote
1
Answered by
m0rgoth 75
10 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:

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

Answer this question