local Teleport = workspace.winner -- (winner is the name of a part)
-- teleporting to (Change all TeleportPads to the name of your Part)
function Touch(hit)
if script.Parent.Locked == false and script.Parent.Parent:FindFirstChild("win1").Locked == false then
script.Parent.Locked = true
script.Parent.Parent:FindFirstChild("win1").Locked = true
local pos = script.Parent.Parent:FindFirstChild("win1")
hit.Parent:moveTo(workspace.winner.Position)
wait(1)
script.Parent.Locked = false
script.Parent.Parent:FindFirstChild("win1").Locked = false
end
end
script.Parent.Touched:Connect(Touch)
COMMUNITY QUESTION
How to fix this "moveTo is not a valid member of Accessory" ?
1 answer
Hello, phupha19534!
You just need to check if what touched the part is parented to a player
local Teleport = workspace.winner -- (winner is the name of a part)
-- teleporting to (Change all TeleportPads to the name of your Part)
function Touch(hit)
if script.Parent.Locked == false and script.Parent.Parent:FindFirstChild("win1").Locked == false then
if game.Players:GetPlayerFromCharacter(hit.Parent) then --Checks if what touched is part of a player model
script.Parent.Locked = true
script.Parent.Parent:FindFirstChild("win1").Locked = true
local pos = script.Parent.Parent:FindFirstChild("win1")
hit.Parent:MoveTo(workspace.winner.Position) -- Its "MoveTo" not "moveTo"
wait(1)
script.Parent.Locked = false
script.Parent.Parent:FindFirstChild("win1").Locked = false
end
end
end
script.Parent.Touched:Connect(Touch)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Fixed your code block.
hit.Parent.Parent, not hit.Parent