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

Moving Fish in a pool randomly?

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

3 comments

0

You'd have to use Vector3.new() to create a new Vector3. I'd use a bodyposition tho.

0

Thanks!

0

I also have another question, How do I make the numbers generated by math.random change everytime?

1 answer

✓ Accepted answer

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

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