Hello, everyone! I was trying to script something when I discovered that it wasn't working. Is anyone able to assist me? I would appreciate every single help. I wanna check if they have a the gamepass, if they don't I check if they are in the for i,v list, if they are not, I want to kick them.
Here is my script:
local Premium = {0} local MPS = game:GetService("MarketplaceService") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) game.Players.PlayerAdded:Connect(function(plr) if MPS:UserOwnsGamePassAsync(plr.UserId,1031940432432423432402) then print("User joined with Beta Access Gamepass!") else for i,v in pairs (Premium) do if v == player.UserId then print("Beta Access was given to this user manually.") else plr:Kick("You sadly do not have access to Beta Version.") end end end end) end) end)
From Roblox Studio, click the Game Settings from the Home tab, go to Options, and turn "Enable Studio Access to API Services" on.
EDIT: Noticed you also had a second PlayerAdded listener. That is unnecessary. Since you are checking for beta access and kicking if they don't have it, you only need to listen to PlayerAdded once instead of CharacterAdded.
local Premium = {0} local MPS = game:GetService("MarketplaceService") game.Players.PlayerAdded:Connect(function(plr) if MPS:UserOwnsGamePassAsync(player.UserId,1031940432432423432402) then print("User joined with Beta Access Gamepass!") else for i,v in pairs (Premium) do if v == player.UserId then print("Beta Access was given to this user manually.") else plr:Kick("You sadly do not have access to Beta Version.") end end end end)