MoveTo is not a valid member of Accessory Error

Hello, Im having a problem using teleporters, this are free models and have this script:

-- local Teleport = "ToMoon"
function Touch (hit) 
	if script.Parent.Locked == false and script.Parent.Parent : FindFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:FindFirstChild(Teleport).Locked=true
		local Pos = script.Parent.Parent:FindFirstChild(Teleport)
	hit.parent:moveTo(Pos.Position) wait(1)script.Parent.Locked = false script.Parent.Parent:FindFirstChild(Teleport).Locked = false
	    end
	       end
	script.Parent.Touched:connect(Touch)

Parts are called “To Earth” and “To Moon”

Sometimes and not always, this error apears in console when touching the teleport pad, and of course, I dont get teleported
image

I searched the error and Im not the only one with this problem, but, I couldnt fix it with those previous posts.

Any help is really appreaciate it

2 Likes

Try this:

-- local Teleport = "ToMoon"
function Touch(Hit) 
  if script.Parent.Locked == false and script.Parent.Parent:FindFirstChild(Teleport).Locked == false then
    script.Parent.Locked = true
    script.Parent.Parent:FindFirstChild(Teleport).Locked = true
    local Pos = script.Parent.Parent:FindFirstChild(Teleport)
    Hit.Parent.Humanoid:MoveTo(Pos.Position)
    wait(1)
    script.Parent.Locked = false
    script.Parent.Parent:FindFirstChild(Teleport).Locked = false
  end
end

script.Parent.Touched:Connect(Touch)

Please use variables and separate lines for your code so that they are indented.

Accessory has no function called MoveTo. Mayble try the part inside the accessory?

With this code this error appears:
image

I dont really understand programming sorry, this are literally free teleports, I just see all the teleports in free models have this error, may you be more specific or clear?

Then try this:

-- local Teleport = "ToMoon"
local SP = script.Parent

function Touch(Hit) 
  if SP.Locked == false and SP.Parent:FindFirstChild(Teleport).Locked == false then
    SP.Locked = true
    SP.Parent:FindFirstChild(Teleport).Locked = true
    local Pos = SP.Parent:FindFirstChild(Teleport)
    local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
    if Humanoid then
      Humanoid:MoveTo(Pos.Position, Pos)
    end
    wait(1)
    SP.Locked = false
    SP.Parent:FindFirstChild(Teleport).Locked = false
  end
end

SP.Touched:Connect(Touch)

Same error, do I have to put that script in both teleport pads? Thats what Im doing

So, the accessory instance is not a part that can be seen in the game, and if its an accessory thats wearable, you can just get the BasePart inside it which has a move to function.

If you’re going to make an or chain to determine the humanoid, why not just run:

local  humanoid = hit:FindFirstAncestorWhichIsA("Model"):FindFirstChild("Humanoid")

That’s because I’ve never looked at the “FindFirstAncestor” functions.

I would love to understand what you mean hahaha, but sorry, I dont understand

I saw that all teleports in Toolbox have the same problem, do you guys know any simple teleport pad that know works fine?
Also, do you guys understand why sometimes it works and sometimes it doesnt? it is just random

This might help you:

local Teleport1 = nil -- change this to the path of one of your tp pads
local Teleport2 = nil -- change this to the path of the other tp pad
local DelayTime = 1 -- change this to whatever you want

local Debounce = {}

Teleport1.Touched:Connect(function(Hit)
  local Character = Hit.Parent
  if Character then
    local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
    if HumanoidRootPart then
      if Debounce[Character.Name] then
        local TimeNow = tick()
        if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
          Debounce[Character.Name] = nil
        else
          return
        end
      end

      Debounce[Character.Name] = {
        LastTeleported = tick()
      }

      Character:SetPrimaryPartCFrame(Teleport2.CFrame)
    end
  end
end)

Teleport2.Touched:Connect(function(Hit)
  local Character = Hit.Parent
  if Character then
    local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
    if HumanoidRootPart then
      if Debounce[Character.Name] then
        local TimeNow = tick()
        if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
          Debounce[Character.Name] = nil
        else
          return
        end
      end
      
      Debounce[Character.Name] = {
        LastTeleported = tick()
      }

      Character:SetPrimaryPartCFrame(Teleport1.CFrame)
    end
  end
end)

Sorry for not knowing, but, what is the path of one of the tp pads? What am I supposed to write there?

That means like

workspace.TeleportPads.teleportPad1

They are in the workspace and look like this: image

So how should I write it then?

Send a screenshot of the whole workspace (including the Office TP model of course).

The workspace is really long and Its impossible to take a full screenshot
It is located in the Workspace, its a model, nothing strange

You should use

local Teleport1 = workspace:WaitForChild("Office TP"):WaitForChild("ToEarth")
local Teleport2 = workspace:WaitForChild("Office TP"):WaitForChild("ToMoon")
local DelayTime = 1 -- change this to whatever you want

local Debounce = {}

Teleport1.Touched:Connect(function(Hit)
  local Character = Hit.Parent
  if Character then
    local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
    if HumanoidRootPart then
      if Debounce[Character.Name] then
        local TimeNow = tick()
        if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
          Debounce[Character.Name] = nil
        else
          return
        end
      end

      Debounce[Character.Name] = {
        LastTeleported = tick()
      }

      Character:SetPrimaryPartCFrame(Teleport2.CFrame)
    end
  end
end)

Teleport2.Touched:Connect(function(Hit)
  local Character = Hit.Parent
  if Character then
    local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
    if HumanoidRootPart then
      if Debounce[Character.Name] then
        local TimeNow = tick()
        if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
          Debounce[Character.Name] = nil
        else
          return
        end
      end
      
      Debounce[Character.Name] = {
        LastTeleported = tick()
      }

      Character:SetPrimaryPartCFrame(Teleport1.CFrame)
    end
  end
end)
2 Likes

And by the way, you only have to use 1 script for that to work. Remove the scripts inside your tp parts and insert a script inside the TP Office model and paste the code there.