Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited by DeceptiveCaster 4 years ago
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)
0
Fixed your code block. DeceptiveCaster 3761 — 4y
0
hit.Parent.Parent, not hit.Parent DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
Ad

Answer this question