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

How would I randomly change the postion of a model?

Asked by
Kblow1 53
6 years ago

How would i make a model spawn and randomly move it. I have this but you cant use Position on a model from what i know

while wait(3) do
    local pos1 = math.random(-256, 256)
    local pos2 = math.random(-256, 256)

    local drop = game.ReplicatedStorage.AirDrops.Drop
    drop:Clone().Parent = game.Workspace
    game.Workspace.Drop.Position = Vector3.new(pos1, 10, pos2)
end

1 answer

Log in to vote
0
Answered by
Z_DC 104
6 years ago

If Drop is a Model object, Models have a method called :MoveTo() which moves the whole object relative to it's primary part, if existent.

You can also use SetPrimaryPartCFrame on an object to move the primary part, and thus the whole object with it.

while wait(3) do
    local pos1 = math.random(-256, 256)
    local pos2 = math.random(-256, 256)

    local drop = game.ReplicatedStorage.AirDrops.Drop
    drop:Clone().Parent = game.Workspace
    game.Workspace.Drop:MoveTo(Vector3.new(pos1, 10, pos2))
end

Ad

Answer this question