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

How do you make a part travel with a player?

Asked by
Lodok3 18
5 years ago
TrackingPart = Instance.new("Part", game.Players.LocalPlayer)
while true do
TrackingPart.Parent = game.Players.LocalPlayer
TrackingPart.Name = "TrackingPart"
TrackingPart.Transparency = 1
wait(1)
print(TrackingPart.Position) 
end

Its not moving the TrackingPart along with the humanoid.

0
How could it be? Why would you think it was going to. DinozCreates 1070 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

You were setting the part's Parent to a value without a Position property. You need to set the Position property of the part to the character in workspace

local player = game.Players.LocalPlayer -- This variable does not represent your player in workspace.
local char = workspace:WaitForChild(player.Name)-- This variable represents your player in workspace.
local hrp = char:WaitForChild("HumanoidRootPart") -- this is a variable for the HumanoidRootPart of your player in workspace.
local part = Instance.new("Part")
part.Name = ("TrackingPart")
part.Size = Vector3.new(2,2,2)
part.Transparency = 1
part.Anchored = true
part.Parent = char -- parent the object into 3D space after setting its properties, not before
while true do
    wait()
    part.Position = hrp.Position - Vector3.new(2,-2,2) -- this will offset the HumanoidRootPart position and position the part away from it slightly
end
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I've had the same issue trying to add fire to a player! R6-only games:

local TrackingPart = Instance.new("Part")
local player = game.Players:GetFirstChild("Humanoid").Torso -- Any other body part will not work for R6
TrackingPart.Position = player.Position
TrackingPart.Parent = player
TrackingPart.CanCollide = false -- If can collide is on the player may glitch
TrackingPart.Transparency = 1
TrackingPart.Anchored = true -- We do not want the part to fall
while true do
        wait(1)
        print("The tracking part has seen the user at "... TrackingPart.Position... ".")
end

R15-only games:

local TrackingPart = Instance.new("Part")
local player = game.Players:GetFirstChild("HumanoidRootPart").Torso -- Any other body part will not work for R15
TrackingPart.Position = player.Position
TrackingPart.Parent = player
TrackingPart.CanCollide = false -- If can collide is on the player may glitch
TrackingPart.Transparency = 1
TrackingPart.Anchored = true -- We do not want the part to fall
while true do
    wait()
        part.Position = player.Position - Vector3.new(2,-2,2)
end
while true do
        wait(1)
        print("The tracking part has seen the user at "... TrackingPart.Position... ".")
end -- It is recommended to put two separate while true do's or the wait will interfere with the other while true do

If none of these work, get back to me asap!

0
I changed the script form saying 'local player = game.Players:GetFirstChild("HumanoidRootPart").Torso' to 'local player = game.Players:WaitForcChild("HumanoidRootPart").Torso' but there was an infinite yield. Lodok3 18 — 5y
0
You cant get character parts from the players MagneticISO 2 — 5y

Answer this question