Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to fix this "moveTo is not a valid member of Accessory" ?

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)

2 comments

0

Fixed your code block.

0

hit.Parent.Parent, not hit.Parent

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.