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

I have no errors but the script doesn't work. Why is that? Please help thanks

before i give the script, please dont criticize me as i am new to scripting, thnx for understanding.

--this is the script i am having problem with.
--also please dont criticize the creative strings

local CreateNewPart = Instance.new("Part", workspace)

function CreatingParts(name, position)
	CreateNewPart.Position = position
	CreateNewPart.Name = name
	print("Done")
end


CreatingParts("Help", Vector3.new(1,0,0))
CreatingParts("LOL", Vector3.new(2,0,0))
CreatingParts("IHML", Vector3.new(3,0,0))
CreatingParts("HMM", Vector3.new(4,0,0))
CreatingParts("meow", Vector3.new(5,0,0))
CreatingParts("Bomb", Vector3.new(6,0,0))
CreatingParts("Solid", Vector3.new(7,0,0))
CreatingParts("IDKWHATNAMEISHOULDGIVE", Vector3.new(8,0,0))
CreatingParts("IDK2", Vector3.new(9,0,0))
CreatingParts("IDK3", Vector3.new(10,0,0))


1 comment

0

move local CreateNewPart inside the function

1 answer

✓ Accepted answer

There are two problems I can see with this.

The first, as mentioned by kkfilms_1 is that the variable is outside of the function. This means that it simply calls every part as the same thing, simply renaming and moving.

The second, which I think is why you only had 4 left, is that they were unanchored. As they collide with other parts, specifically the others made, they will get large velocities, fly off the map, and be despawned. Anchoring should solve that solution.

With both of these implementations, your code should you something like this:

function CreatingParts(name, position)
	local CreateNewPart = Instance.new("Part", workspace)
	CreateNewPart.Anchored = true    
	CreateNewPart.Position = position
    CreateNewPart.Name = name
    print("Done")
end


CreatingParts("Help", Vector3.new(1,0,0))
CreatingParts("LOL", Vector3.new(2,0,0))
CreatingParts("IHML", Vector3.new(3,0,0))
CreatingParts("HMM", Vector3.new(4,0,0))
CreatingParts("meow", Vector3.new(5,0,0))
CreatingParts("Bomb", Vector3.new(6,0,0))
CreatingParts("Solid", Vector3.new(7,0,0))
CreatingParts("IDKWHATNAMEISHOULDGIVE", Vector3.new(8,0,0))
CreatingParts("IDK2", Vector3.new(9,0,0))
CreatingParts("IDK3", Vector3.new(10,0,0))

I tested it for myself, and it worked as far as I saw. If you have any further problems, please do reply.

Hope this helped.

6 comments

0

ya, thnx it worked and created some parts in the workspace but i cant see them

0

are they under the baseplate?

0

They shouldn't be? can you see them in the explorer?

0

yes, i got it, it was out of the map

0

Great. Glad to have helped. Make sure to select either of our answers as correct, so the thread is marked as correct.

0

how do i select this as the answer?

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