Hello scripters! I have a little problem. So i have 4 buttons for each team. Each button has 2 scripts inside them, who are ran on same time. First script kills player once button is pressed, and it works fine, but the second script is supposed to check is the player in certain rank in my group and then switch he's team if he is. The second script is not working. Ill post below the 2 scripts, maybe they are not compatible with each other.
Kill script:
function onButtonClicked() script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 end script.Parent.MouseButton1Click:connect(onButtonClicked)
Team change script:
function Click(mouse) if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(268422) print ("IS IN A GROUP!") if player:GetRoleInGroup(268422) == "Marked" then script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright green") end script.Parent.MouseButton1Down:connect(Click)
You do not need two separate scripts, so here is a single block of code that is the solution to your question.
function Click(mouse) script.Parent.Parent.Parent.Parent.Parent.Character.Health=0 if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(268422) print("IS IN A GROUP!") if player:GetRankInGroup(268422) ~= 0 then -- Look for Reason (A) below this code, script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright green") end -- You forgot the end(s) for the if(s) end end script.Parent.MouseButton1Down:connect(Click)
Reason (A): If you were to use GetRoleInGroup, it would look for the group's rank name (For Example, Recruit [LR] ; General [HR]), but with GetRankInGroup, the Rank is the number from editing the group's roles, such as the guest's rank 0. With "GetRankInGroup(##) ~= 0", it would not allow any rank 0, which is a person not associated with the group, to activate the team switch