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

Gamepass team only code is not appearing in the roblox game but it is in roblox studio?

Asked by 2 years ago

Hi fellow coders! I am trying to make a code for gamepass only team. I put the script in a remote event and everything works in roblox studio but when i play the game in roblox it doesnt work. I applied edits published it etc but still and issue. Is this problem with my code or do I need to activate something like a setting. Anyways here is my code below:

script.Parent.OnServerEvent:Connect(function(player)
    local GamepassId = "23857004"
    local MarketplaceService= game:GetService("MarketplaceService")
    local OwnsGamePass = false
    print("beforeifstatement")
    if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
        print("afterifstatement")
        OwnsGamePass = true
            print("insidefunction")
            if OwnsGamePass == true then
                player.Team = game.Teams.Security
                local hum = player.Character:FindFirstChild("Humanoid")
                hum.Health = 0
        end
    end
end)

Answer this question