Okay, I'm making a group. That is based off of the Secure Contain Protect foundation. Now, I need help making it so only a certain rank. Can switch to the Foundation Personnel team. I need the rank number as 1. The code below shows the basic team change, but I need help making it so only ranks can switch to this team through roblox groups. Please respond if you have the time, thank you.
function Click(mouse) if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(703942) then script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright blue") end end
script.Parent.MouseButton1Click:connect(Click)
Alright, try using a Lua Code block next time, so it can make your code clearer and easier to understand. From what you said on the description it seems as if you want a certain rank on your group to access a team. For that, we must use the 'GetRankInGroup() == 'Rank Number' method.
Your script would look like this: Note: I made your code a bit simpler, so that you wouldn't need to call every 'Parent' of the object to get the player.
Player = game.Players.LocalPlayer function Click(mouse) if Player:IsInGroup(--[[GroupID]]) and Player:GetRankInGroup(--[[GroupID]]) == 1 --[[Rank # Example:"1" or "255" etc]] then Player.TeamColor = BrickColor.new("TeamColor") end end script.Parent.MouseButton1Click:connect(Click)
If you want to make it so that every person above rank '1', including rank '1' to be able to join the Team, you must use >= (greater than or equal to). Same with less than <= . If you just want it to be one rank, as above only use two '=' signs. Hope this helped.
This might work:
--In a localscript inside the button local Player = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function() if Player:GetRankInGroup(--GroupId) > 1 then Player.TeamColor = BrickColor.new(--BrickColor) end end)