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

Instance.new not creating parts?

script.Parent.Touched:connect(function(hit)
		if hit.Planks and hit.Name == "Log" then
			planks = hit.Planks.Value
		for i = 1, tonumber(planks) do
			part = Instance.new("Part")
			part.Position = Vector3.new(hit.Position)
			part.Size = Vector3.new(1, 9.6, 0.2)
			hit:Remove()
		end
	end
end)




I'm clueless one why it won't work.

Planks is an intvalue in Log

4 comments

0

Whats the output??

0

new is not a valid member. Line 8

0

And also. Even when I Remove the invalid line #8. It should work with out it but it doesn't even create the parts. Should I use tonumber()?

0

edited script above

1 answer

✓ Accepted answer

The problem you are having is that you are not assigning the part's parent. Do you want it in the Workspace, Lighting, etc? There are two ways to assign the parent of it,

One: part = Instance.new("Part", Workspace),

Two: part = Instance.new("Part") part.Parent = Workspace

1 comment

0

OH! Thank you. I just assumed it would create the part in workspace. Lesson learned. Never assume anything in Lua

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