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

New part inside part at random position?

Asked by
Kblow1 53
6 years ago

So im trying to make a script that spawns parts inside of part at random positions... So the part is huge. I want other small parts to spawn inside. Here is what i have so far.

while wait() do
    local pos1 = math.random(script.Parent.Position.X, script.Parent.Position.Z)
    local pos2 = math.random(script.Parent.Position.X, script.Parent.Position.Z)

    local part = Instance.new("Part", script.Parent)
    part.Name = "Yes"
    part.Size = Vector3.new(15,15,15)
    part.Position = Vector3.new(pos1,350,pos2)
    wait(1)
    script.Parent.Yes:Destroy()
end

There is an error in console and here is what it says

 Workspace.Area.Script:2: bad argument #2 to 'random' (interval is empty)
0
bump please help!! Kblow1 53 — 6y

Answer this question