How can I make it that if player is in a group from a module then a frame shows up

generally, I wanna make a blacklist script. If the player is in a group from a module list, the reason text will change to the reason the group is in the module

module

local group = {
	{group = "group", reason = "cool", groupId = 123},
}

return group
local GroupList = require(script.GroupList)
local Player = game:GetService("Players").LocalPlayer

local Group = script.Parent.Group
local Reason = script.Parent.Reason


if isInBlacklist then
	Player.PlayerGui.Scoreboards:Destroy()
	Player.PlayerGui.PlayerList:Destroy()
	Player.PlayerGui.Start:Destroy()
	Player.Backpack:ClearAllChildren()
	script.Parent.Header.Text = "BLACKLISTED"
	Group.Text = "You cannot access this game"
	Reason.Text = "You have been blacklisted. Reason: " .. blacklistedGroup.reason
end

Can anyone modify this script to that if player is in the groups that are in the module, it shows the frame with the group ID and the groups reason for blacklist?

5 Likes

Sure!

local GroupList = require(script.GroupList)
local Player = game:GetService("Players").LocalPlayer

local Group = script.Parent.Group
local Reason = script.Parent.Reason

local blacklistedGroup

for _,v in ipairs(GroupList) do
   if Player:IsInGroup(v.groupId) then
       blacklistedGroup = v
   end
end

if blacklistedGroup then
	Player.PlayerGui.Scoreboards:Destroy()
	Player.PlayerGui.PlayerList:Destroy()
	Player.PlayerGui.Start:Destroy()
	Player.Backpack:ClearAllChildren()
	script.Parent.Header.Text = "BLACKLISTED"
	Group.Text = "You cannot access this game"
	Reason.Text = "You have been blacklisted. Reason: " .. blacklistedGroup.reason
end
2 Likes

Returns error:

Argument 1 missing or nil
	if Player:IsInGroup(v.groupID) then

Try replacing v.groupID with v.groupId

You can loop through every group and check if the player is in each group.

Code:

local GroupList = require(script.GroupList)
local Player = game:GetService("Players").LocalPlayer

local Group = script.Parent.Group
local Reason = script.Parent.Reason

local blacklistedGroup = nil

for i, groupData in ipairs(GroupList) do
	if Player:IsInGroup(groupData.groupId) then
		blacklistedGroup = groupData
		
		break
	end
end

if blacklistedGroup then
	Player.PlayerGui.Scoreboards:Destroy()
	Player.PlayerGui.PlayerList:Destroy()
	Player.PlayerGui.Start:Destroy()
	Player.Backpack:ClearAllChildren()
	script.Parent.Header.Text = "BLACKLISTED"
	Group.Text = "You cannot access this game"
	Reason.Text = "You have been blacklisted. Reason: " .. blacklistedGroup.reason
end
2 Likes

No errors, the frame stops appearing

This aswell stops showing the frame.

Could you elaborate? The if statement works fine, maybe you forgot to make it visible?

its in the scripts, at the top it would make the frame invisible

when the player is in that group, the frame becomes visible.
it seems to be when it gets the group and reason

nvm, i changed smt and it started working from this script. thanks.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.