This answer is to be only used as a reference, and no other purpose.
Just like I explained in my comments, you can set a part's - or parts' - CFrame property to that of another part; it's the same with Position, but Position makes it so that part(s) go above a part so that you don't have to do extra work with CFrame to accomplish that.
Here's an example:
local lastPart = nil
function createNewPart()
local newPart = Instance.new('Part')
if lastPart then
newPart.Position = lastPart.Position
else
newPart.CFrame = game.Workspace.BasePlate.CFrame + Vector3.new(0, 1, 0)
end
newPart.Parent = game.Workspace
lastPart = newPart
end
for i = 1, 2 do
createNewPart()
end
And when you fire the example code, you will notice that two parts have been created, and one's on top of one another.
Now, from your second code, there's a noticeable but easy to fix problem. The problem I'm speaking of is how you retrieve the player's Character, Humanoid and Torso (no link given because the wiki doesn't have a docu on it ;/ ). When you retrieve them directly as is, your code is subjected to the great possibility of breaking because one of the three may not be there when the code executes. (What I mean is one of them may be nil, not existent yet.)
To counter this, you can use the following:
~ CharacterAdded
- This will fire when the player's character loads. (A function of a player only.)
~ WaitForChild
- Will yield the code until a child of the same name as the argument given to the function exists within the selected parent that the function is called upon. (OH MY LORDS THAT'S A LOT OF JUNK- I MEAN INFO!)
An example of how to use these is the following:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
print(character.Name)
local newPart = Instance.new('Part')
newPart.Name = 'Part'
spawn(function()
print('I\'m waiting!')
game.Workspace:WaitForChild('Part')
print('Torso is here!')
end)
wait(2)
bewPart.Parent = game.Workspace
Notice how it took a bit for the prints to fire? That's because when the WaitForChild function is called upon with an argument, it'll yield the code until the specific object enters the parent, and then let the rest of the code pass.
Aaaaaand that's all there's to it actually. lol
Stuff touched on, but didn't go into great detail about
Attempt to index 'information' (a nil value)
Ok... Lets try this instead:
Stuff mentioned and touched on
CFrame
Position
Character and Humanoid
The CharacterAdded Function
The WaitForChild Function
The Spawn Coroutine
IT WORKED!!!! :O
Hope this helped you in any way! :D
4 comments
Parts (or parts in general) have a two properties: Position and CFrame (Coordinate Frame). You can set either of the properties to the player's character (but for CFrame, you need to retrieve a part of the player's character, like the Torso); however, if you want the part to be on top of the part, Position is the way to go.
To add onto my last comment: Think of CFrame as a definite position, while Position is where you don't have to set up calculations to have it be above other parts.
Okay Let me try something and Ill let ya know if i fixed it.
Okay I'm using position and it is still not working I'll update the question.