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

How do I make it so the game kicks people that aren't a group rank or dont have a gamepass?

Asked by 4 years ago

I am making a gamepass that will allow people to see my beta game, if they don't have it they will be kicked. But, I want to make it so a certain group rank can still play without the gamepass, such as the developers. Can someone help? I'm bad at this stuff, lol.

this is what I tried, but it does not work.

01local MPS = game:GetService("MarketplaceService")
02local ID = 11377785
03local Player = game:GetService("Players").LocalPlayer
04 
05game.Players.PlayerAdded:Connect(function(plr)
06    if MPS:UserOwnsGamePassAsync(plr.UserId,ID) then
07      elseif Player:GetRankInGroup(5791590) <= 255 then
08 
09    else
10        plr:Kick("You do not own the required gamepass.")
11    end
12end)
0
How is it not working? Any errors? User#30567 0 — 4y
0
Remember to pcall Async functions User#30567 0 — 4y
0
It did not show any errors maddiesswrld 30 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try this one here it should work

01local MarketPlaceService = game:GetService("MarketplaceService")
02local GamepassId = 11377785
03local GroupId = 5791590
04local RequiredRank = 255
05local KickMessage = "You do not own the required gamepass."
06game.Players.PlayerAdded:Connect(function(player)
07    if not MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) and player:GetRankInGroup(5791590) <= 255 then
08        player:Kick(KickMessage)
09    end
10end)

tell me if it works

Ad

Answer this question