New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Part.Position is Confused. Why?

Asked by 14 days 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
Feahren 3662 Moderation Voter Community Moderator
14 days ago
Edited 14 days 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