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

Moving Fish in a pool randomly?

Asked by 5 years ago
Edited 5 years ago

I am trying to figure out a way to move my fish object in a specific area randomly. Is there an easy way to do so? If you have any ideas please share. Thanks, I also tried this script, but it gives me this error: attempt to call global 'Vector3' (a table value)

Script here:

                 fish = script.Parent
                  X = math.Random(10)
                  Y = math.Random(10)
                  Z = math.Random(10)
                  while wait(0.5) do
                  fish.CFrame = fish.CFrame + Vector3(X, Y, Z)
            end
0
You'd have to use Vector3.new() to create a new Vector3. I'd use a bodyposition tho. TiredMelon 405 — 5y
0
Thanks! mixgingengerina10 223 — 5y
0
I also have another question, How do I make the numbers generated by math.random change everytime? mixgingengerina10 223 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

The function is spelt random, not Random.

Vector3 is a table, while .new() is a function inside it.

local fish = script.Parent

local x = math.random(1, 10)
local y = x
local z = y 

while wait(.5) do
    fish.CFrame = fish.CFrame + Vector3.new(x, y, z)
end
Ad

Answer this question