Roblox ClickDetector 有问题

Roblox ClickDetector Having Problems

无论我 运行 在编辑器还是在本地服务器中,我在 Roblox 上的脚本都无法运行。 我不知道哪里出错了,所以我就 post 整个脚本

player = game.Players.Player --you might want to change this...
target = Vector3.new(20, 10, 20) --...and this

local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = workspace["Decal and teleporter"]
ClickDetector.MaxActivationDistance = 1000



function fadeTo(a, b, c)
    for transparency = a, b, c do
    --go from a to b, counting by c

        for _, part in pairs(player.Character:GetChildren()) do
        --for each of the objects in the character,

            if part:IsA("BasePart") then
            --check if it's a part, and if so

                part.Transparency = transparency
                --set its transparency
            end
        end
        wait(0.1)
    end
end

ClickDetector.MouseClick:Connect(function()
    fadeTo(0, 1, 0.1) --fade out
    player.Character.HumanoidRootPart.CFrame = target --teleport the player
    fadeTo(1, 0, -0.1) --fade back in
end)

我应该先发布然后在那里测试吗?

编辑:我犯了一个大错误。我将零件尺寸设置为 1000,但忘记更改 MaxActivationDistance。感谢大家的帮助。我不再需要它了

问题出在ClickDetector的函数上,看

target = Vector3.new(20, 10, 20) --...and this
player.Character.HumanoidRootPart.CFrame = target

改为

target = CFrame.new(Vector3.new(20, 10, 20)) --...and this
player.Character.HumanoidRootPart.CFrame = target

说明: 您不能将 CFrame 值设置为 Vector3 值,其中 CFrame 是 Vector3、Orienation 等