Problems with changing teams, involving being in a group and stuff

so i have problems with my team changer
cant really say anything else of it, just look what i do here
code:

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	if plr:IsInGroup(7417509) then
		if plr:GetRankInGroup(7417509) >= 15 then
			plr.Team = game.Teams.Instructors
		end
	end
end)
3 Likes

I take it you want people to be able to change team if they are in the group “7417509” and they are a greater than the role 15?

1 Like

Make sure if you want to access the LocalPlayer it is running in a LocalScript, as it can’t be used in a ServerScript, to my knowledge.

Try this instead,

UnrefinedRank = script.Parent.Parent.Parent.Parent.Parent:GetRankInGroup(7417509)

function Click(mouse)

if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(7417509) then

	if UnrefinedRank > 15 then

script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Institutional white")

script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0

end

end

end

script.Parent.MouseButton1Click:connect(Click)

hm, and what is that supposed to do?

Make sure you are using a regular script, not localscript

  local ClickDetector = script.Parent


    ClickDetector.MouseClick:Connect(function(player)
        if player:GetRankInGroup(7417509) == 255 then
           print("Player is the owner of the group")
        else
            print("Player is not the owner of the group")
        end
    end)

Changes the users team to the team colour if there > 15 and in the group (7417509)

So what does >= mean and what does > mean?
the exact same or do they have a difference

means “greater than” or “higher than” meaning if I was in the group 7417509 and lower than the rank “15” this will not work as the script will only allow players with the rank 15 +.

so, both of them mean the exact same or not?

Im not a very experienced coder but I THINK “=” is “Equal to” meaning if I was the rank 15 and the script was ( if plr:GetRankInGroup(7417509) == 15 then ) only the rank 15 can change to this team.

its not ==, infact it is >= meaning it will be any rank thats above the rank ID

Hmm ok. Have you managed to get it working yet?

it doesnt give errors, but it also doesnt team me
do the script locations matter?

Where have you put the line of code?

i put the scripts inside the buttons

Are you still using this code?

1 Like

yes i am using that code, just having to change it like a million times

Try this one maybe?

function Click(mouse)

if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(7417509) then

script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Burgundy")

script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0

end

end

script.Parent.MouseButton1Click:connect(Click)

what is this parent.parent and so on for?