Block that does not move randomly when I touch it

i want to make a block move to random places on the baseplate but it only moves once when I touch it. :frowning_face_with_open_mouth:

And how are you expecting people to help you with this if you’re not providing your code?

1.function move()
2. script.Parent.position = math.random (20,20,20)
3.end)
4.
5.script.Parent.touched:connect (move)

i’m not good at scripting so please help.
thanks!

I don’t really know how to make it move randomly multiple times.

local Part = script.Parent
local BaseRange = 20

local function Move()
    Part.Position = Vector3.new(math.random(-BaseRange, BaseRange), math.random(-BaseRange, BaseRange), math.random(-BaseRange, BaseRange))
end

Part.Touched:Connect(Move)

Everyone learns at their own pace, so here are a couple of things to know about:

  • Position can be taken as what’s known as a Vector3 value, or a vector in 3d space, and there are 3 parameters for using it

  • math.random() requires 2 arguments:

    • The first would be the smallest range you want to search for (Say you don’t want to go below 3, you would do math.random(3, 5), it would print a number: 3, 4, or 5

    • The second is the highest range it can go

  • Referencing variables at the start of your script can make it easier to grab them for later use