Hi, I am trying to get the players name from a folder then teleport them to a part
Script
local TP = game.Workspace.TP
script.Parent.Value.Changed:Connect(function(val)
script.Parent.Parent.Part.BillboardGui.TextLabel.Text = "Queue: "..val.."/2"
if script.Parent.Value.Value == 2 then
for v, name in pairs(script.Parent.Queue:GetChildren()) do
print(name)
game.Workspace:FindFirstChild(name).PrimaryPart:MoveTo(TP.Position)
TP.Value.Value = true
local PpP = Instance.new("StringValue")
PpP.Name = name
PpP.Parent = TP.Players
end
wait(2)
print("ajsd")
end
end)
try changing it to this if you want to make the player walk to the part:
local TP = game.Workspace.TP
script.Parent.Value.Changed:Connect(function(val)
script.Parent.Parent.Part.BillboardGui.TextLabel.Text = "Queue: "..val.."/2"
if script.Parent.Value.Value == 2 then
for v, name in pairs(script.Parent.Queue:GetChildren()) do
print(name)
game.Workspace:FindFirstChild(name).Humanoid:MoveTo(TP.Position) -- use humanoid here
TP.Value.Value = true
local PpP = Instance.new("StringValue")
PpP.Name = name
PpP.Parent = TP.Players
end
wait(2)
print("ajsd")
end
end)
I think it only works if you use the Humanoid instead of the PrimaryPart.
If you want to teleport the player without making him walk use this:
local TP = game.Workspace.TP
script.Parent.Value.Changed:Connect(function(val)
script.Parent.Parent.Part.BillboardGui.TextLabel.Text = "Queue: "..val.."/2"
if script.Parent.Value.Value == 2 then
for v, name in pairs(script.Parent.Queue:GetChildren()) do
print(name)
game.Workspace:FindFirstChild(name):SetPrimaryPartCFrame(TP.CFrame)
TP.Value.Value = true
local PpP = Instance.new("StringValue")
PpP.Name = name
PpP.Parent = TP.Players
end
wait(2)
print("ajsd")
end
end)
for v, name in pairs(script.Parent.Queue:GetChildren()) do
print(name)
game.Workspace:FindFirstChild(name):PivotTo(TP.CFrame)
TP.Value.Value = true
local PpP = Instance.new("StringValue")
PpP.Name = name
PpP.Parent = TP.Players
end
Ok after reading your script I realized the issue, the Queue was a folder and the names that were in there was a sting value with the players name so I was trying to find the string value in workspace so all I had to change was