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

Part.Position is Confused. Why?

Asked by 4 years ago

Hello. I was trying to make a part that follows the camera's x, y, and z position. Could you help me out? There's no error, it just doesn't work.

local owner = game.Players.iiDkOffical
local head = Instance.new("Part")
head.Name = "Head"
local group = Instance.new("Model")
group.Name = owner.Name.." - Game Time: "..elapsedTime()
head.Parent = group
head.Size = Vector3.new(1,1,1)
head.Position = Vector3.new(game:GetService("Workspace").CurrentCamera.CFrame)

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Position is a three-dimensional vector, to modify a userdata, you must cast the respective datatype to it. You casted a CFrame, which contradicts the datatype of Position. To ensure you're casting a proper Vector3 of CFrame, use the .p component which represents the Positional constant.

Part.Position = workspace.CurrentCamera.CFrame.p --// Returns a Vector3 automatically
Ad

Answer this question