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

Item location Randomizer not working?

Idea The idea of this script is to get the object Statue and move it to a location within the specified area.
Problem The problem is that I get the error MoveTo is not a valid member of Part
Code:

local model = game.Workspace.Treasure2.Statue
local minTime = 1
local maxTime = 1 
local xPos = {-6.5, 28.5}
local yPos = {0.5, 0.5}
local zPos = {-22.5, 2.5}

while wait(math.random(minTime, maxTime)) do
local m = model:Clone()
local x = math.random(xPos[1], xPos[2])
local y = math.random(yPos[1], yPos[2])
local z = math.random(zPos[1], zPos[2])
m:MoveTo(Vector3.new(x,y,z))
end

2 answers

✓ Accepted answer
local model = game.Workspace.Treasure2.Statue
local minTime = 1
local maxTime = 1
local xPos = {-6.5, 28.5}
local yPos = {0.5, 0.5}
local zPos = {-22.5, 2.5}
 
while wait(math.random(minTime, maxTime)) do
local m = model:Clone()
local x = math.random(xPos[1], xPos[2])
local y = math.random(yPos[1], yPos[2])
local z = math.random(zPos[1], zPos[2])
m.Parent = game.workspace
m.Position = Vector3.new(x,y,z)
end
  1. It's m.Poistion

  2. For some reason, I have to make the clones parent workspace, or it doesn't work.

3 comments

0

I was first

0

You didn't answer the question fully nor did you supply a "fixed" script

0

True, sorry hard to type on iPhone so I try to make my answers elaborate and quick

From what I can see you need to do move to for the model not the part. So do m.Parent:MoveTo

3 comments

0

its not in a model

0

MoveTo isn't in parts only in models so try m.Position = Vector3.new(x,y,z)

0

Thumbs up if this is right :)

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