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

Random location cloning help?

Can some one help me create a script which will clone a model and put it in a random spot? or maybe help me with the clone it on top of a random voxel or location.

randomlocation = 
for I = 1
randomlocation = math.random(2044, 252, 2044)
model = game.ServerStorage.ShadowEnemy
copy =game.ServerStorage.model:clone-- messed up
copy.parent = game.Workspace
copy.Postion = randomlocation
end

2 comments

0

It sounds like you are asking us to make a script for you. Please refrain from doing this in the future.

0

k (but i dont know how to do that kind of script)

2 answers

workspace.Model:clone():MoveTo(Vector3.new(math.random(-1000, 1000), 0, math.random(-1000, 1000)))

So, what you need to start out with is cloning the model,

model = game.Lighting.Modely:clone() -- Location
model.Parent = game.Workspace -- Parent it
model:MakeJoints() -- Keep it from breaking apart

Then you need to position it using :MoveTo() and math.random():

model:MoveTo(Vector3.new(math.random(-512,512), 5, math.random(-512,512))) -- Modify the ranges and the y to your liking

So all together:

model = game.Lighting.Modely:clone() -- Location
model.Parent = game.Workspace -- Parent it
model:MakeJoints() -- Keep it from breaking apart
model:MoveTo(Vector3.new(math.random(-512,512), 5, math.random(-512,512))) -- Modify the ranges and the y to your liking

3 comments

0

can you add a Z cordinate?

0

There is a Z coordinate: Vector3.new(math.random(-512,512) is the X, 5 is the Y, math.random(-512,512) is the Z)

0

oh!

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