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

Why doesn't position, vector3, or CFrame work for this on line 11?

So I'm trying to make this part practically follow the players torso but when I make it try to update and follow it doesn't work..

local Player = game.Players.localPlayer
game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:wait()
	plr.Character:WaitForChild("Torso")
	local torso = plr.Character.Torso
	local part = Instance.new("Part", game.Workspace)
	part.Transparency = 0.2
	part.CanCollide = false
	part.Size = Vector3.new(4,4,4)
while wait(0.1) do
	part.Position = CFrame.new(torso.Position)
end
end)

.

1 answer

✓ Accepted answer

part.Position requires a Vector3; you won't be able to give it something from CFrame.new

Simply

part.Position = torso.Position

will work (since both are Vector3s).


However, setting Position will not move the object to precisely that point - it will set it on top, in the available space above.

Usually when moving objects, you want to use .CFrame:

part.CFrame = CFrame.new(torso.Position)

or, if you want it to have the same orientation as torso, simply use

part.CFrame = torso.CFrame

1 comment

0

Omg lol ok thank you I feel like an idiot now and it works

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