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

How come I can't clone a part into workspace?

Asked by
Yeevivor4 155
9 years ago

Hi, thank you for reading. What I'm trying to do here is that after every 10 seconds, a part named "Foil" is spawned into the workspace. The Foil is moved to where the part is. The problem is that at it says

15:23:52.967 - Workspace.Script:9: unexpected symbol near '=='

Material = game.Lighting.Loot:getChildren()

while true do 
    print("Spawning")
    wait(10)
    for i = 1, #Material do
    if Material[i] ~= nil then
    if Material[i]:findFirstChild("Foil") then
    Material[i]:findFirstChild("Foil"):clone() == Material
    Part = game.Workspace.Part
    if Part ~= nil then
    Material:MoveTo(Part.Position)
                end
            end
        end
    end 
end

1 answer

Log in to vote
2
Answered by 9 years ago

This is because you're not setting anything to Material, but rather the clone made by the 'Clone' method.

Also, you were trying to parent a Part to a table which isn't possible.

To fix this, simply add the 'Parent' property to show that is where it's location should be:


Material = game.Lighting["Loot"]GetChildren() while true do print("Spawning") wait(10) for i = 1, #Material do if Material[i] and Material[i]:findFirstChild("Foil") then Material[i]["Foil"]:Clone().Parent = workspace Part = workspace:FindFirstChild("Part") if Part then Material:MoveTo(Part.Position) end end end end
0
There was an error: Workspace.Script:9: bad argument #3 to 'Parent' (Object expected, got table) Yeevivor4 155 — 9y
0
I think when it says Workspace.Script.9, it meant Workspace.Script.10 cause i deleted the green words Yeevivor4 155 — 9y
0
Resolved DigitalVeer 1473 — 9y
Ad

Answer this question