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

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

Asked by 4 years ago

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))


0
move local CreateNewPart inside the function kkfilms_1 68 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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.

0
ya, thnx it worked and created some parts in the workspace but i cant see them AriyanHacker29 22 — 4y
0
are they under the baseplate? AriyanHacker29 22 — 4y
0
They shouldn't be? can you see them in the explorer? NinjaMandalorian 252 — 4y
0
yes, i got it, it was out of the map AriyanHacker29 22 — 4y
View all comments (2 more)
0
Great. Glad to have helped. Make sure to select either of our answers as correct, so the thread is marked as correct. NinjaMandalorian 252 — 4y
0
how do i select this as the answer? AriyanHacker29 22 — 4y
Ad

Answer this question