So in my game only people in the group can play as patient but visitors cant. I want visitors/non group members be able to join the team. Here is the script that doesnt let them join it.
function checkPermissions(teamName, player)
for i=1,#Depends.Teams do
local team = Depends.Teams[i]
if game.Teams[teamName] == Depends.Teams[i].Team then
– Check for group permissions to join the team
for group, rank in pairs(team.Permissions.Groups) do
local plrRank = player:GetRankInGroup(group)
– Player is a high enough rank
if plrRank >= rank then return true end
end
-- Check for gamepass permissiosn to join the team
for _, gamepass in pairs(team.Permissions.Gamepasses) do
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepass) then
-- Player owns a gamepass
return true
end
end
-- No group ranks or gamepasses owned
return false
end
end
If you’re able to post the entire script in perhaps a screenshot, I’ll be able to assist you with what you’d need! The formatting of that post is rather funky, and some variables within aren’t defined in what’s posted.
Setting the required rank to 0(Rank 0 = non-group members) allows anybody to join the team. Go test to see whether or not this works, and like @Cytheur said, there are some missing variables within the script.
function checkPermissions(teamName, player)
for i=1,#Depends.Teams do
local team = Depends.Teams[i]
if game.Teams[teamName] == Depends.Teams[i].Team then
– Check for group permissions to join the team
for group, rank in pairs(team.Permissions.Groups) do
local plrRank = player:GetRankInGroup(group)
– Player is a high enough rank
if plrRank >= 0 then return true end
end
-- Check for gamepass permissiosn to join the team
for _, gamepass in pairs(team.Permissions.Gamepasses) do
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepass) then
-- Player owns a gamepass
return true
end
end
-- No group ranks or gamepasses owned
return false
end
end
end
Not sure if this would be your solution, but below is a script that when a player joins, it’ll check to see if they meet either requirement. One is a game pass requirement, the other is a group rank requirement. Should be easy for you to edit as need be.
-- Services
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local Teams = game:GetService("Teams")
-- Variables to Edit
local Group_ID = 000000
local Rank_Needed = 50
local Gamepass_Needed = 00000
local Patients_Team = "Patients"
local Gamepass_Team = "Gamepass_Team"
-- Core
Players.PlayerAdded:Connect(function(player)
if player:GetRankInGroup(Group_ID) >= Rank_Needed then
player.Team = Teams:FindFirstChild(Patients_Team)
end
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, Gamepass_Needed) then
player.Team = Teams:FindFirstChild(Gamepass_Team)
end
end)