【问题标题】:Roblox gamepass prompt not showing upRoblox 游戏通行证提示未显示
【发布时间】:2022-01-18 07:03:12
【问题描述】:

我试图制作一款标题全小写之类的愚蠢喜剧 Roblox 游戏。该游戏的前提是您必须付费才能做任何事情;走路,跳跃,开门等。我写了一个脚本,功能如下:首先它检查你是否有游戏通行证,然后如果你没有游戏通行证,它会在你按下w时打开一个购买游戏通行证的提示, a、s 或 d。我试图运行打印语句来查看是否是游戏通行证提示调用不起作用,或者它是否是其他类似按键检测的东西,但无济于事。 (顺便说一句,它位于一个本地脚本中,其中包含一个名为“walkspeednew”的禁用脚本,该脚本在您购买游戏通行证后将您的步行速度设置为正常。名为“WalkSpeed”的脚本在您开始游戏时运行,并将您的步行速度设置为 0。 )

local ps=game:GetService("Players")
local gamePassId=26063683
ps.PlayerAdded:Connect(function(player)
    local hasPass=false
    local success,message=pcall(function()
        hasPass=MarketplaceService:UserOwnsGamepassAsync(player.UserId,gamePassId)
    end)
    if not success then
        warn('gamepass loading error')
        return
    end
    if hasPass then
        game.Workspace.WalkSpeed:Destroy()
        script.walkspeednew.Disabled=false
    end
end
UserInput.InputBegan:Connect(function(input,gameProccesedevent)
    if not hasPass then
        if input.KeyCode==Enum.KeyCode.W or input.KeyCode==Enum.KeyCode.A or input.KeyCode==Enum.KeyCode.S or input.KeyCode==Enum.KeyCode.D then
            local player=game.Players.LocalPlayer
            Game:GetService("MarketplaceService"):PromptPurchase(player,gamePassId)
        end
    end
end)

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    为此使用 UserInput 并不方便。 Humanoid 有一个名为MoveDirection 的属性,它以单位向量的形式确定玩家移动的方向。您可以访问 Magnitude 属性并查看它是否大于 0 以了解是否存在主动移动,而无需依赖于他们的移动。 HumanoidStateType 或 UserInput 是。

    【讨论】:

      猜你喜欢
      • 2020-11-08
      • 2019-11-08
      • 1970-01-01
      • 2010-11-06
      • 1970-01-01
      • 2020-03-28
      • 2016-07-14
      • 1970-01-01
      • 2021-06-19
      相关资源
      最近更新 更多