Button Group/Team lock

Does anyone know how to make group lock button it is whenever someone wants to click the button they must to be in the team if the person is not in team then they’re not able to click the button thanks ^-^

For group:

local button = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local groupId = 0 --change to id of group

button.Mouse1ButtonClick:Connect(function()
	if player:IsInGroup(groupId) then
		--do code
	end
end)

For team:

local button = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local teamName = "" --change to name of team

button.Mouse1ButtonClick:Connect(function()
	if player.Team == teamName then
		--do code
	end
end)

Organisation:

image

2 Likes

do you have one for like for click detector one i want to make for my car spawner so other people that are not in my team cant spawn the car

For group:

local clickDetector = script.Parent
local groupId = 0 --change to id of group

clickDetector.MouseClick:Connect(function(player)
	if player:IsInGroup(groupId) then
		--do code
	end
end)

For team:

local clickDetector = script.Parent
local teamName = "" --change to name of team

clickDetector.MouseClick:Connect(function(player)
	if player.Team == teamName then
		--do code
	end
end)

Organisation:

image

1 Like

Im pretty sure its brick color, correct me if im wrong.

1 Like

https://developer.roblox.com/en-us/api-reference/property/Player/Team

2 Likes

And if you want to check the rank in the group

local button = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local groupId = 0 --change to id of group
local rankId = 255 -- change to id of the rank

button.MouseButton1Click:Connect(function()
	if player:GetRankInGroup(groupId) >= rankId then
                -- something --
	end
end)
2 Likes