So whenever I run the script, the fish, (Who is the one moving) juts sinks to the bottom of the tank and stays there. Any help?
fish = script.Parent while true do for i=1,20 do fish.CFrame = fish.CFrame + Vector3.new(0.1,0,0) wait(0.1) end for i=1,31 do fish.CFrame = fish.CFrame * CFrame.fromEulerAnglesXYZ(0,0.1,0) wait(0.01) end for i=1,20 do fish.CFrame = fish.CFrame - Vector3.new(0.1,0,0) wait(0.1) end for i=1,31 do fish.CFrame = fish.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.1,0) wait(0.01) end end
I made this base upon our script, there are a lot of improvements to make but I did not have time to finish it.
You need to store the angle and apply it to the cframe so that it faces the direction you are traveling and you need to add a method to stop if going beneath the floor.
Hope this helps you.
fish = script.Parent function curX() return fish.CFrame.x end function curY() return fish.CFrame.y end function curZ() return fish.CFrame.z end function ran(low, high) -- hole numbers only i think? return math.random(low, high) end while true do for i=1,ran(1, 100) do fish.CFrame = CFrame.new(curX() + 0.2, curY()+ 0.1, curZ()+ ran(10,100)/100) wait(0.1) end for i=1,ran(10,360) do fish.CFrame = CFrame.new(curX(), curY(), curZ()) * CFrame.fromEulerAnglesXYZ(0,i/100,0) wait(0.01) end for i=1,ran(1, 100) do fish.CFrame = CFrame.new(curX() - 0.2, curY() -0.1, curZ() - ran(10,100)/100) wait(0.1) end end