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

Why doesnt it copy it?

Asked by 8 years ago
local Part = game.ReplicatedStorage.Part
local Names = {"Part", "Part2"}
Position = 84.98, 48.33, -225



for i,v in pairs(Part :GetChildren()) do
if v.Name == Names[math.random(1, #Names)] then
wait(0.1)
local Part = v:Clone()
Part .Position = Vector3.new(Position)
Part .Anchored = true
end
end


2 answers

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
8 years ago

You do need to parent it and tab it just like NotSoNorm said but also.. You have 2 variables called "Part"

local Part = game.ReplicatedStorage.Part --Variable called "Part"
local Names = {"Part", "Part2"}
Position = 84.98, 48.33, -225



for i,v in pairs(Part:GetChildren()) do
    if v.Name == Names[math.random(1, #Names)] then
        wait(0.1)
        local Part = v:Clone() --Variable called "Part"
        part.Parent = game.Workspace -- change game.Workspace to path
        Part.Position = Vector3.new(Position)
        Part.Anchored = true
    end
end

NotSoNorm might be right but I feel that this should not have 2 variables w/ then same name.

Ad
Log in to vote
0
Answered by
NotSoNorm 777 Moderation Voter
8 years ago

You have to define where it goes! It will not appear because it doesn't spawn until you parent it. (oh yeah and tab your code nob)

local Part = game.ReplicatedStorage.Part
local Names = {"Part", "Part2"}
Position = 84.98, 48.33, -225



for i,v in pairs(Part:GetChildren()) do
    if v.Name == Names[math.random(1, #Names)] then
        wait(0.1)
        local Part = v:Clone()
        part.Parent = game.Workspace -- change game.Workspace to path
        Part.Position = Vector3.new(Position)
        Part.Anchored = true
    end
end

Answer this question