Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Instance.new not creating parts?

Asked by 6 years ago
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

0
Whats the output?? AmericanStripes 610 — 6y
0
new is not a valid member. Line 8 YellowoTide 1989 — 6y
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()? YellowoTide 1989 — 6y
0
edited script above YellowoTide 1989 — 6y

1 answer

Log in to vote
3
Answered by
Aethex 255 Moderation Voter
6 years ago

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

0
OH! Thank you. I just assumed it would create the part in workspace. Lesson learned. Never assume anything in Lua YellowoTide 1989 — 6y
Ad

Answer this question