local TeleporterFolder = game.Workspace.NPCsci.Teleporters:GetChildren()
local TeleportPosition = CFrame.new(game.Workspace.NPCsci.Teleporters.B.Position)
--
--[[
game.Players.PlayerAdded:Connect(function(player)
local backpack = player:WaitForChild("Backpack")
if backpack then
local Part = backpack:WaitForChild("Suitcase").detect
if Part then
Part.Touched:Connect(function(hit)
if hit == partToLookFor then
Part.CFrame = TeleportPosition
end
end)
else
print("Part is equal to nil")
end
else
print("Backpack is equal to nil")
end
end)
game.Players.PlayerAdded:Connect(function(player)
local suitcase = script.Parent.Parent.Parent.Detector:WaitForChild("Tool").detect
suitcase.Touched:Connect(function(hit)
print("test")
if hit == partToLookFor then
suitcase.CFrame = TeleportPosition
end
end)
end)
]]
for i,v in ipairs(TeleporterFolder) do
if v:IsA("BasePart") then
local partToLookFor = v
game.Players.PlayerAdded:Connect(function(player)
local suitcase = script.Parent.Parent.Parent.Detector:WaitForChild("Tool").detect
suitcase.Touched:Connect(function(hit)
print("test")
if hit == partToLookFor then
suitcase.CFrame = TeleportPosition
end
end)
end)
end
end
This is my script above i dont know why is it doing that
what are you trying to do with this script i dont see the A reference but I do see where you have have this making multi connections to the player added which should be declared outside of the for loop
what exactly are you trying to achieve with this script
GetChildren:() only get the children of the said instance. It doesn’t get the children of children of that instance.
Maybe that’s the problem?
If you want to get the children of children as well use GetDescendants()
I couldn’t understand what is the point of your script so I thought this might be the issue. If it isn’t then good luck.
Also if possible show a screenshot of the “Teleporters” in the explorer.
I tried using getdescendants and it still shows the same error at output. I don’t know why is GetChildren nor GetDescendents is already getting a children
I think there is a small problem.
it says "A is not a valid member of Part “Workspace.NPCsci.Teleporters.A”
Here it is trying to find A part inside the A part which doesn’t exist according to the screenshot of explorer you sent earlier.
Get the children of Teleporters not A
How do I do that? My script is already getting childrens of Teleporter
local TeleporterFolder = game.Workspace.NPCsci.Teleporters:GetDescendants()
local TeleportPosition = CFrame.new(game.Workspace.NPCsci.Teleporters.B.Position)
for _,v in pairs(TeleporterFolder) do
local partToLookFor = v.A
local suitcase = script.Parent.Parent.Parent.Detector:WaitForChild("Tool").detect
suitcase.Touched:Connect(function(hit)
print("test")
if hit == partToLookFor then
suitcase.CFrame = TeleportPosition
end
end)
end
Simply just remove the .A
v is already A. So A.A doesn’t exist.
That’s why its saying that
When you get children of the teleporters, it gets A, A, B.
for i,v runs the code on A then the other A then B not on the folder itself.
Keep that in mind