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

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

Asked by
Prioxis 673 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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
0
Omg lol ok thank you I feel like an idiot now and it works Prioxis 673 — 9y
Ad

Answer this question