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

Brick Moving problem?

Asked by 10 years ago

I currently have a script that makes a brick follow you. Problem is, whenever the player moves, the brick lags behind a bit. Is there anyway I can make the brick move more accurately with the players torso?


function onPlayerEntered(player) player.CharacterAdded:connect(function(char) char.Torso.Transparency = 1 while wait(.0001) do script.Parent.Transparency = 0 script.Parent.Size = Vector3.new(2,2,1) script.Parent.CanCollide = false script.Parent.CFrame = CFrame.new(char.Torso.Position.X, char.Torso.Position.Y, char.Torso.Position.Z) * CFrame.Angles(0, math.rad(char.Torso.Rotation.Y), 0) end end) end game.Players.PlayerAdded:connect(onPlayerEntered)

1 answer

Log in to vote
0
Answered by 10 years ago

Weld the object to the character's torso. It is more efficient than what you are doing.

function onPlayerEntered(player)
    player.CharacterAdded:connect(function(char)
        char.Torso.Transparency = 1;
        local weld = Instance.new("Weld", char.Torso);
        weld.Part0 = weld.Parent;
        weld.Part1 = part -- part you want to attach to Torso;
    end)
end)

game.Players.PlayerAdded:connect(onPlayerEntered);
Ad

Answer this question