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

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

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

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

3 comments

0

There was an error: Workspace.Script:9: bad argument #3 to 'Parent' (Object expected, got table)

0

I think when it says Workspace.Script.9, it meant Workspace.Script.10 cause i deleted the green words

0

Resolved

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