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

because the text button is the script’s parent.

so could this script work? because it doesnt

local ClickDetector = script.Parent


ClickDetector.MouseClick:Connect(function(player)
    if player:GetRankInGroup(7417509) >= 4 then
        player.Team = game.Teams.Instructors
    end
end)

About that, your code is firing on the Client, fire a RemoteEvent so it will be on the Server.

Since this is a local script (I guessed because you use the local player), you can’t change the team since the server won’t know it changed. So I suggest you to fire a remote event to the server, and change the team from there, instead of from the local script.

Should look like this:

--The local script in the button
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(fucntion()
--check if the player is in the group and has the role
game:GetService("ReplicatedStorage").RemoteEvent:FireServer() --Whatever your remote name is
end)

And in the server:

game:GetService("ReplicatedStorage").RemoteEvent.OnServerEvent:Connect(function(plr)
     --Change the team and whatever you want here.
end)

This solution will work only with click detector, but OP is using GUIs, and MouseButton1Click won’t give you the player, and GUIs should be changed from local scripts.

2 Likes

Ran through the question too fast, thought the problem was concerning the utilization of the GetRankInGroup function but looking through it again this seems to be what he was looking for. :+1:

1 Like