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

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

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by
Yionee 65
7 years ago

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)
0
Thanks,i was struggling with this kristibezatlliu1111 33 — 7y
Ad

Answer this question