如果没有游戏通行证则进行传送

时间:2019-04-06 18:30:12

标签: roblox

如果他没有游戏通行证,我正试图传送到另一个地方 但它不起作用!

我有 作为父母 文本按钮->本地脚本-> screengui-> Startergui

这是我的代码:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = game:GetService("Player") 
local gamePassID = 6180124  -- Change this to your game pass ID
    local hasPass = false
local TeleportService = game:GetService("TeleportService")

    -- Check if the player already owns the game pass
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
    end)

    -- If there's an error, issue a warning and exit the function
    if not success then
        return
    end

    if hasPass == true then
        local Gui = script.Parent.Parent
        local Window = Gui:WaitForChild("Frame")
        Window.Visible = false
    end

if hasPass == false then
  game:GetService("TeleportService"):Teleport(3043589235)
  TeleportService:Teleport(3043589235, player)
end
---now onclick
 script.Parent.MouseButton1Click:connect(function()
    -- Check if the player already owns the game pass
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
    end)

    -- If there's an error, issue a warning and exit the function
    if not success then
        return
    end

    if hasPass == true then
        print("HasPass")
        local Gui = script.Parent.Parent
        local Window = Gui:WaitForChild("Frame")
        Window.Visible = false
    end

if hasPass == false then
  game:GetService("TeleportService"):Teleport(3043589235)
  TeleportService:Teleport(3043589235, player)
end
end)

如果他没有游戏通行证,我想把他传送回去。 如果我单击按钮或等待。什么都没发生。 怎么了?

0 个答案:

没有答案