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

How to Get A Part Follow Player With No Lag?

Asked by 8 years ago

Hello, I need a part to follow the player's torso with absolutely no lag. I have tried BodyPosition, but I need it to constantly follow where the player is, so I have to reset the position in a loop with a 0.01 interval, but I don't think Roblox can handle that interval... so how do I make it follow the player where it is without lag? Also, I there any other method that isn't welding, because I need to rotate the arms also.

1
You can still rotate welded parts using CFrames aquathorn321 858 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

The following script uses rocket propulsion to fire a projectile that follows the player by using brick welded above the player as a target. Keep in mind you might have to change the MaxSpeed and MaxThrust values of the rocket depending on the outcome you want and the weight of the part.

local p = Instance.new("Part")
p.FormFactor = "Custom"
p.BottomSurface = "Smooth"
p.TopSurface = "Smooth"
p.Size = Vector3.new(3,3,3)
local c = Instance.new("RocketPropulsion",p)
c.Name = "rocket"



game.Players.PlayerAdded:connect(function(player)
    player.Character:connect(function(character)
        local u = p:Clone()
        u.Size = Vector3.new(0,0,0)
        u.Cancollide = false
        u.Transparency = 1
        u.Parent = character
        local w = Instance.new("Weld",character.Torso)
        w.Part0 = character.Torso
        w.Part1 = u
        w.C0 = CFrame.new(0,9,0)
        local clone = p:Clone()
        p.CFrame = CFrame.new(character.Torso.Position + Vector3.new(0,8.5,0)
        p.Parent = workspace
        p.rocket:fire()
    end
end)
Ad
Log in to vote
0
Answered by 8 years ago
local plr = game.Players.LocalPlayer
local char = plr.Character or plr:CharacterAdded:wait()

while wait() do
local part = script.Parent
local t = char.Torso

part.Position = t.Position

end)

Answer this question