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

Part goes above the player instead of where it should go?

So this has been quite annoying,here is a example script.

local Part = Instance.new("Part")
Part.Parent = game.Workspace
Part.Position = game.Players.LocalPlayer.Character.Torso.Position
Part.Anchored = true
Part.CanCollide = false
Part.Size = Vector3.new(10,1,10)

So whats going on,is that i instance this part,but instead of going in the torso's position,it goes above the player's head,I'm guessing it has to do with collisions,but,how do i fix it?

I Nyeed help AAAAAAAAAAAAAAAAAAAAAAAAAAAA

1 answer

✓ Accepted answer

Except on a few specific situations, changing the position of a part will place the part in the closest open space above other parts. If you want the Part to appear in the same space as player's torso, you should set the CFrame of the Part to the Torso's CFrame.

Also, changing the Size property after changing the Position or CFrame of the part will cause the part to appear above player in the next open spot above the player.

local Part = Instance.new("Part", workspace) --less typing for setting parent
Part.Anchored = true
Part.CanCollide = false
Part.Size = Vector3.new(10, 1, 10) -- set size before CFrame
Part.CFrame = character.Torso.CFrame

as an extra note: since this uses CFrame, the part will have the same rotation matrix of the Torso's CFrame. If you don't want the part to have the torso's rotations, use this line instead (last line in previous example):

Part.CFrame = CFrame.new(character.Torso.Position)

1 comment

0

Thanks,i was struggling with this

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