【问题标题】:How do I teleport the player if they have a gamepass in Roblox如果玩家在 Roblox 中有游戏通行证,我如何传送玩家
【发布时间】:2021-12-28 19:28:58
【问题描述】:

我已尝试遵循几个指南,但尚未找到解决方案。

  local id = 1180578480
local marketService = game:GetService("MarketplaceService")
function onTouched(m)
    p = m.Parent:findFirstChild("Humanoid")
    if marketService:UserOwnsGamepassAsync(user.UserId, id) then
        if p ~= nil then
            p.Torso.CFrame=CFrame.new(0,8,9) 
        end
    end
    end
script.Parent.Touched:connect(onTouched)

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    首先,确保将 id 设置为游戏通行证 id - 这似乎有点太高了。

    请记住 Lua 区分大小写,因此您需要使用 FindFirstChild 而不是 findFirstChild 和 UserOwnsGamePassAsync 而不是 UserOwnsGamepassAsync。

    记住您拥有哪些变量以及它们存储的内容 - 您尚未定义用户变量,但您在第 5 行使用了一个,并且您正在尝试获取人形机器人的躯干而不是角色。

    local id = 1180578480
    local marketService = game:GetService("MarketplaceService")
    function onTouched(m)
        local p = game.Players:GetPlayerFromCharacter(m.Parent)
        if p then
            if marketService:UserOwnsGamePassAsync(p.UserId, id) then
                p.Character.Torso.CFrame=CFrame.new(0,8,9) 
            end
        end
    end
    script.Parent.Touched:Connect(onTouched)
    

    【讨论】:

      猜你喜欢
      • 2022-06-21
      • 1970-01-01
      • 2020-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-20
      • 2018-06-14
      • 2022-10-05
      相关资源
      最近更新 更多